How to get the velocity of my KinematicBody, animated by an AnimationPlayer?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By MikeMikeMike


I’ve animated an KinematicBody with an AnimationPlayer translation property.

How to get the linear (and angular) velocity of the KinematicBody?



P.S.: I need the velocity to move my player (a RigidBody) accordingly with my platform (KinematicBody) by code.

:bust_in_silhouette: Reply From: sash-rc

See an answer about changed position Detecting linear_interpolation movement - Archive - Godot Forum
Basically velocity = (position - old_position) / delta

However you should not move RigidBody with velocity. You should use forces and impulses.

And typically, when a RigidBody rests on a moving KinematicBody it just moves together with platform: you don’t have to do anything extra, like in real life.

Hi sash,

thank you for the link and the basics, this could help.

My RigidBody is a Sphere, and doesn’t rest on my moving KinematicBody. I have to glue it to the KinematicBody somehow, I think the best way is to copy velocities from the KinematicBody to the RigidBody, but KinematicBody has no velocity properties.



P.S.: Yes, the Sphere should use real life physics, but not on moving platforms.

MikeMikeMike | 2021-08-12 17:58