I've got 2 square sprites, and I want to perform something only when they hit from the top, meaning collision from the right side of a sprite will not perform the code.
Any idea on how to check it?
Hi trueicecold Could you break the sprite into two parts, one (at the top) for detecting the collision and the other (at the bottom, but visually a continuation of the top) which just tags along for the ride?
Alternatively you could try some math on collision event regarding the position of both objects.
Develop games in your browser. Powerful, performant & highly capable.
see 2 possible solutions:
1.- Use an invisible sprite "dummy", place it just on the top, and check for collisions.
2.- Compare positions of objects in the moment of the hit: If "Y" is lower, the object is higher and comes from above.
(lol, just the same as hundredfold, seems we were writing at the same time...)
I have something similar in my game, a crate is broken if Player is on top.
Square 1 --> On Collision w/ Square 2: Square 1--> (Add what you need here)
(Add Condition) Square 1--> (Compare Y) Y < Square 1.Y
lol clockworkmonster - great minds think alike
Great stuff, thanks all!