I have several circles on the screen, placed on different locations (all dynamic box2d bodies).
I want to add another circle, with an initial velocity of say x, y
. I want this body to move freely, as if there's no gravity. Make all it's collisions 100% elastic.
I tried setting elasticity to 1, but if I drop it from the top, it doesn't touch the ceiling again. I want it to just keep moving in the direction it was set to, unless a collision changes its direction.
To explain this further, a simple implementation of what I want would be this, in a square container, with a circular body.
when collides ->
set body.velocityX to -body.velocityX
set body.velocityY to -body.velocityY
Of course this doesn't work if I have bodies in between.
Suggestions in any language with box2d framework or pseudocode would be appreciated.