0
votes

I have two dynamic bodies with a Contact Listener and lets call the bodies A and B.

When body (A.tag == Car) collides with body (B.tag == Cat) I don't want the car to be pushed back, I want the cat to be pushed but not push back on the car (Causing the car to stop too!)

I feel like I'm missing something simple but can someone please explain how I can manipulate the b2Contact so that one object does not change is velocity but the other does?

Thanks!

1

1 Answers

0
votes

You can use PreSolve and PostSolve callbacks. In PreSolve save the car velocity, angular velocity, angle and position somewhere - for example, as instance variables on car's userData object. In the PostSolve restore those values back.

PreSolve called just before those bodies collide and PostSolve is called right after the collision - when velocities are changed. Doesn't tried it myself, but should work.