- Home /
How to calculate speed without rigid body
How can I calculate speed without a rigid body? I am using this so if the character reaches a certain speed it will make the model crossfade into a animation.
Answer by robertbu · Mar 12, 2014 at 04:30 PM
How are you moving your object if you don't have a Rigidbody? If you are using a CharacterController, then you can likely use CharacterController.velocity. If you are moving it through direct manipulation of the Transform, then your speed will be encoded in your movement code.
If you really need to do it without any internal information. You can take save the position each frame. The the magnitude of the difference between the last position and the current position divided by Time.deltaTime will be the speed.
var speed = (transform.position - lasPos).magnitude / Time.deltaTime;
Rather than a single frame, you may want to average the result over several frames, or you may want to only sample at fixed intervals.
Thanks, this is more useful now if using jobs where we can't access Rigidbody.
Your answer
![](https://koobas.hobune.stream/wayback/20220613140054im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
How to calculate speed without rigid body 0 Answers
Animated Billboard or Animated Model? 2 Answers
Handling Animation and movement speed 0 Answers
Changing a child's animation speed via parents script. 0 Answers
Animation speed (backward) 1 Answer