Impact

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

1 decade ago by flexelektro

Hello !
My starting point is the physics demo with the box2d plugin.

I wanted to find out when a entity has ground under his feets.

in my player.js:
for( var edge = this.body.m_contactList; edge; edge = edge.next ) {
        
        // Get the normal vector for this contact
        var normal = edge.contact.m_manifold.normal;
        console.log(normal.y); 
}
...

This should work, but it behaves different depending on if i stand on a entity or a collision tile.

standing on a tile: normal.y is SMALLER 0 (like it should)
standing on an entity(crate ie): normal.y BIGGER 0

i really can not find out... any help ?

1 decade ago by flexelektro

I now "solved" this problem by
if(edge.contact.m_shape1.m_body.m_type == 2){normaly *= -1;}

with
normaly = normal.y;

But i stiil dont understand the "why".

Propably collision tiles, which have a ##this.body.m_type = 1## have a contact normal which shows in the other direction ?
So many questions ... i guess i should learn box2d first ....
Page 1 of 1
« first « previous next › last »