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 kwikshot

I have an EntityPlayer class with collision code that looks like this:

collides: ig.Entity.COLLIDES.PASSIVE,

collideWith: function (other, axis) {
console.log('hey');
}

and an EntityEnemy class with collision code that looks like this:

collides: ig.Entity.COLLIDES.PASSIVE,


For some reason, collideWith() is never called even when they collide, but if I set up the entities type and checkAgainst, check() is called, and I can't really understand why.

[player.js http://pastebin.com/5C6GiRKF]

[enemy.js http://pastebin.com/djbmaJPJ]

1 decade ago by kwikshot

Sorry the formatting on the links at the bottom broke, it should be

http://pastebin.com/5C6GiRKF

and

http://pastebin.com/djbmaJPJ

1 decade ago by Neeko

Edit: Sorry, didn&039;t read that you already tried setting up the #checkAgainst and type properties already.

Reading through lib/impact/entity.js, it looks like the collideWith function will only get called when either the entities collides property is set as ig.Entity.COLLIDES.ACTIVE or g.Entity.COLLIDES.FIXED. Since you set them as PASSIVE, solveCollision won&039;t be called, and thus neither will #collideWith.

1 decade ago by lTyl

From the documentation:

In ACTIVE vs. LITE or FIXED vs. any collisions, only the weak entity moves, while the other one stays fixed. In ACTIVE vs. ACTIVE and ACTIVE vs. PASSIVE collisions, both entities are moved. LITE or PASSIVE entities don't collide with other LITE or PASSIVE entities at all.

1 decade ago by kwikshot

Ahh thanks I took this as meaning that they just wouldn't bounce off each other, but I see how this works now, since collideWith only makes sense if we're guaranteed that they won't be colliding the frame after.
Page 1 of 1
« first « previous next › last »