Collision detection question

Hi guys!

Another question regarding collisions. In games when the player collide with an enemy, player dies. When the player jump onto the enemy, in this case enemy dies.

How can I verify that the player jumped onto the enemy? How can I make difference between these two events? What would be the code itself?

Thank you in advance!

Read this blog post and pay attention to the part about a ‘foot sensor’:

https://coronalabs.com/blog/2013/02/19/more-physics-tricks-explained/

This technique can be used to detect if you ‘drop onto’ and enemy vs collide horizontally of from below.

Hi @appsdelmar,

Another option (more simple) may be to just compare the Y position of the player vs. the enemy when they collide. If the player’s “feet” are approximately at the level of the enemy’s “head” then you could consider the enemy as dead. @roaminggamer’s mention of the “foot sensor” is also a great option, but if your game is very simple, like “Super Mario jumping on goombahs”, then the simple Y comparison method may be sufficient.

Take care,

Brent

Read this blog post and pay attention to the part about a ‘foot sensor’:

https://coronalabs.com/blog/2013/02/19/more-physics-tricks-explained/

This technique can be used to detect if you ‘drop onto’ and enemy vs collide horizontally of from below.

Hi @appsdelmar,

Another option (more simple) may be to just compare the Y position of the player vs. the enemy when they collide. If the player’s “feet” are approximately at the level of the enemy’s “head” then you could consider the enemy as dead. @roaminggamer’s mention of the “foot sensor” is also a great option, but if your game is very simple, like “Super Mario jumping on goombahs”, then the simple Y comparison method may be sufficient.

Take care,

Brent