How to retrieve Actual Speed value

Hello guyz,

I’m trying to retrieve the actual speed of my character, so I can know when he’s stopped, stuck etc…
I’m using AIPath on my character and it works fine. But I don’t find where to search the actual speed.

I know there is a Speed variable but it’s used as a MaxSpeed. The thing I want to find is the actual speed of my character.
How can I do to find this value? Or how to calculate it? Or create a new variable in the script to show it?

Can someone help me please?


That depends on what you are using to move the object.
If you have a CharacterCollider attached, CharacterCollider.velocity should do the trick, same for Rigidbody.
If you are just using transform movement, there is unfortunately no direct way to access it, but you could easily modify the Update method in the AIPath script to just save the temporary variable called “dir” to a public variable called e.g “velocity” and then you could use it.

Yep, definitely yes! I checked with the velocity and It worked. I now able to determine if my character is static for a certain amount of time. So I can know when he’s stuck.
Thanks Aron for your time!
Have a good one!