Is there a way to stop an object from moving left/right?

I have a ball that is bouncing on the screen using the physics engine. I was wondering if this is an easy way to apply a linnear force to the ball in the exact opposite direction it’s moving so that it stops moving left / right but is still free to fall down?

Haven’t tried it, but what happens if you change the bodyType to static? Will it stop? If so, then change it dynamic and it should fall. Maybe? Dunno, just guessing. :slight_smile:

 Jay

Sure enough that worked. Thanks for the tip, I would have never thought about that. I was taking a much harder way :smiley:

Haven’t tried it, but what happens if you change the bodyType to static? Will it stop? If so, then change it dynamic and it should fall. Maybe? Dunno, just guessing. :slight_smile:

 Jay

Sure enough that worked. Thanks for the tip, I would have never thought about that. I was taking a much harder way :smiley:

You can also do this to set the object’s velocity to 0 so it stops but is still affected by gravity:

[lua]

object:setLinearVelocity( 0, 0 ) – (xVelocity, yVelocity)

[/lua]

You can also do this to set the object’s velocity to 0 so it stops but is still affected by gravity:

[lua]

object:setLinearVelocity( 0, 0 ) – (xVelocity, yVelocity)

[/lua]