0
votes

I have two dynamic object in scene actually these are two balls. But i am not happy with there collision behaviour for example when they have a collision one ball get speedy and one gets slower and some times one ball completely got stop. I know this is normal according to the physics rule but i want static speed even if they collide. Actually i am developing it in coronalabs So here is the code of how i added two balls

  ball1 = display.newCircle(ballx, bally, ball_radius)
  physics.addBody( ball1, "dynamic", { bounce = 1, density =1, friction = 0, radius = ball_radius } )
  ball1:setFillColor( 255,215,0 )
  ball1:setLinearVelocity(500,500)

  ball2 = display.newCircle(ballx+5, bally+25, ball_radius)
  physics.addBody( ball2, "dynamic", { bounce = 1, density =1, friction = 0, radius = ball_radius } )
  ball2:setFillColor( 255,0,0 )
  ball2:setLinearVelocity(500,500)
1

1 Answers

0
votes

This should be achieveable by simply changing your density to 0 and bounce to 1.

physics.addBody( ball, "dynamic", { bounce = 1, density = 0, friction = 0, radius = ball_radius } )

Another approach could be to use the collision detection to set the setLinearVelocity() after a collision. That way the lost force is instantly resat to whatever speed you want the ball to travel at after the collision but in a new direcction.