To animate between two known positions, you can use the pc.Vec3 lerp method to smoothly transition between two vectors:
https://developer.playcanvas.com/api/pc.Vec3.html#lerp
Or a more elaborate way is to use the PlayCanvas tween library:
https://developer.playcanvas.com/en/tutorials/tweening/
Just make sure to use rigidbody.teleport()
on dynamic objects.
Otherwise if you are talking about applying a constant force to push the body towards a direction, your applyForce()
line is correct. Just make sure to do that in your script update method, so it’s applied over several frames.
Otherwise if you are looking in applying a momentary force (impulse), use applyImpulse()
instead.
Hope that helps.
2 Likes
Thank you ! I appreciate your time