Bounce object the same way it came from

Hello i’m pretty new to programming and i have a question.

I’m using the physics.addBody() api in my game and i want an object to bounce the same way it came from not bounce off in the normal direction. How can i accomplish this ?

Hi @snobban,

Probably the best way is to detect the object’s linear velocity in a preCollision event, then forcibly turn it around (reverse the velocity values). Here’s a guide to get you started…

http://docs.coronalabs.com/guide/physics/collisionDetection/index.html#precollision

Take care,

Brent

Hi @snobban,

Probably the best way is to detect the object’s linear velocity in a preCollision event, then forcibly turn it around (reverse the velocity values). Here’s a guide to get you started…

http://docs.coronalabs.com/guide/physics/collisionDetection/index.html#precollision

Take care,

Brent