This forum is read only and just serves as an archive. If you have any questions, please post them on

8 years ago by eLouai

Just wondered how to go about detecting when the player hits the collisionmap to either damage health or change animation or even just to kill outright.


Also I only get a boolean on whether he hit the x or y planes as opposed to a value of how strongly he hit the sides. Was this changed?

My hacked workaround (since it was a 48 game jam) was to change the plugins.joncom.box2d.entity to add the following code
var mx = this.vel.x * ig.system.tick;
var my = this.vel.y * ig.system.tick;
var res = this.pos.x, this.pos.y, mx, my, this.size.x, this.size.y);
this.handleMovementTrace( res );

in the update function.

Here is the link to the game:

Even then the collision detection is sporadic, box2d handles the collisions fine.
Any thoughts?

8 years ago by Joncom

handleMovementTrace is not used because Box2D handles all the movement and collisions now. Take a look at the _isStanding function to see how to check for collisions with the world.

Basically you loop through all the contacts possibly touching the entity body. Then you consider only the contacts that are actually touching. And then you check the properties of the contact to determine stuff like where the collision happened or at what angle, etc.

To see what sort of information a contact makes available to you, see here.
Page 1 of 1
« first « previous next › last »