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 Hazneliel

Hello, how do I make an entity kill another entity and bounce at the same time, imagine a ball breakout game in which a ball kills the bricks and bounces at the same time.

The entity already bounces while the other entity is not killed, but as soon as the other entity is killed it goes trought.

Thank you

1 decade ago by fugufish

could you provide some sample code?

I would do it in the following order:

- Entity A collides with Entity B, (B is fixed)
- Entity A bounces off Entity B (set A's velocity opposite to what it was, with an angle)
- Kill Entity B

1 decade ago by Hazneliel

That sounds good, but the engine should be able to manage that collision isnt it?

1 decade ago by dominic

The problem is that check() is called before the collision is resolved. So if you kill() one of the entities during the check(), there will be no more entity to collide with.

Have a look at the .collideWith() method - it is called on both entities after the collision is resolved, so you could kill() the entity there.

1 decade ago by Hazneliel

Then I will have to use the .collideWith method instead of the check isnt it?? because actually Im not kiling an entity, Im dealingDamage to it and I want to bounce back when I drop its damage to 0
Page 1 of 1
« first « previous next › last »