Selecting only one object when colliding with many

Get help using Construct 2

Post » Mon Aug 13, 2012 10:48 am

Hello,

I'm currently coding a script for my platformer game where when the players' hitbox collides with a box and he presses the action key, he'll be able to pick it up.

The problem however is that there will be cases where his hitbox will be overlapping multiple boxes, and in those cases I'd like to know how I could select - for instance - only the bottommost box?

Comments and ideas would be much appreciated. :-)
B
22
S
5
Posts: 107
Reputation: 2,354

Post » Mon Aug 13, 2012 11:02 am

I would just do a pick nearest object.

But you could also find the one with the lowest IID, it would mean it was the first to spawn.
B
36
S
10
G
6
Posts: 948
Reputation: 11,101

Post » Sun Aug 19, 2012 2:39 am

Thanks for the reply,

I can't get the "nearest object" case to work.

I did the following:
1. If player hitbox overlaps box.
2. If player presses D && Trigger once while true
3. Pick nearest box to hitbox
4. Destroy box.

The problem is that it does not destroy one box. It destroys all boxes that are touching the player hitbox simultaneously.

Can this be fixed somehow?

Again, I only want to pick ONE box at a time.

Thanks.
B
22
S
5
Posts: 107
Reputation: 2,354

Post » Sun Aug 19, 2012 2:43 am

Nevermind, I accidently made an error in the event editor.

It works. Thanks! :-)
B
22
S
5
Posts: 107
Reputation: 2,354


Return to How do I....?

Who is online

Users browsing this forum: 99Instances2Go, Popcan151, Skebab and 12 guests