Is there such a thing as transition.to (easing) for an object's velocity?

I want to use a joystick to move an object in a scene. That object is a physics object and should react to forces (primarily collisions) while still trying to move in the direction the joystick is pointing.

I am currently setting the object’s velocity to the direction the joystick is pointing while it is being held. This works as far as moving the object goes, but it does not react to forces well since its velocity is getting set every frame while the joystick is held.

As such, I was wondering if there was some kind of function similar to transition.to for setting velocity, such that while the joystick is being held the object’s velocity is constantly easing toward the direction being held. If this is possible, when the object receives an external force, it will react and then ease back to the held direction. That way the joystick would work for moving the object while also enabling a tunable resistance to external forces.

Hey Ingulit,

there are two main ways to achieve what you want.

  1. Save the applied forces (may it be via a function or a collision) in a table and add/subtract them each time you update the characters motion. After that decrease the stored forces by multiplying them with 0.1 for example. If they get to low (like < 0.1) remove them from the table.

  2. Use a touch joint to move the character. With the right properties set this will work pretty well. Check out the following links for a better discription:

https://coronalabs.com/blog/2014/08/05/tutorial-physics-joints-explained-part-2/

https://docs.coronalabs.com/daily/guide/physics/physicsJoints/index.html#touch

https://www.youtube.com/watch?v=9u21eSR4O1E

Hey Ingulit,

there are two main ways to achieve what you want.

  1. Save the applied forces (may it be via a function or a collision) in a table and add/subtract them each time you update the characters motion. After that decrease the stored forces by multiplying them with 0.1 for example. If they get to low (like < 0.1) remove them from the table.

  2. Use a touch joint to move the character. With the right properties set this will work pretty well. Check out the following links for a better discription:

https://coronalabs.com/blog/2014/08/05/tutorial-physics-joints-explained-part-2/

https://docs.coronalabs.com/daily/guide/physics/physicsJoints/index.html#touch

https://www.youtube.com/watch?v=9u21eSR4O1E