tutorial-platformer icon indicating copy to clipboard operation
tutorial-platformer copied to clipboard

Faulty enemy collision

Open cchartr opened this issue 10 years ago • 1 comments

Jumping on the enemy hurts the player, not the enemy.

It seems the code assumes that on a collision, response.a will be the player and response.b will be the enemy. This is not always the case. Both the enemy and the player fire a collision response when calling me.collision.check(this), it seems the player fires one with response.a being itself and response.b being the enemy, and for the enemy it's the other way around. Also, the enemy checks whether the player's falling flag is set, but it has been previously unset by the player's collision code, resulting in the enemy not being actually hurt.

The "platformer" example in the melonJS code seems to handle that better. Maybe the tutorial could take inspiration from that.

cchartr avatar May 23 '15 14:05 cchartr

@cchartr This is a bug in melonJS that will be fixed by https://github.com/melonjs/melonJS/issues/574

There's also a thread on the forum where the tutorial issue was reported, including the details of what causes it (and how to add a workaround): https://groups.google.com/forum/#!msg/melonjs/lAS974m-IxU/uqWm7HdoAVYJ

parasyte avatar May 25 '15 22:05 parasyte