Page 2 of 2

Re: Constant speed in the X axis of a body

Posted: Mon Nov 16, 2015 7:17 am
by Z_ReC
First:
Thanks to all who helped! :crazy:

Second:
S0lll0s wrote:
Doctory wrote:switch from the love.physics, it is impossible to get a constant velocity in love.physics without screwing something up
Not really, he just needs to do a few things every frame:
  • get current velocity vector (:getLinearVelocity())
  • normalize and scale it by the target velocity
Now you can either just set it directly (setLinearVelocity()), which might look weird, or instead apply a force:
  • subtract the actual velocity from the target velocity vector
  • apply a force proportional to that difference
Try to duplicate your example, but I could not, you could guide me more? Sorry!

Re: Constant speed in the X axis of a body

Posted: Tue Nov 17, 2015 2:31 pm
by s-ol
If you don't want to mess with the velocity itself you basically read the current velocity, and if it's too slow, apply a force to the right, if its too fast, apply a force to the left to slow it down.