Rigidbody velocity


Hello community,

where is the moving executed from a rigidbody ?

ive got an working moving enemy in my scene, but i want to read out if its moving or not. The actual velocity of my rigidbody stays at 0. I cant find any script which would run the moving in update or fixed update.

Why is my character moving ? In which script updatefunction is the moving called when you just download the asset and run with the given scripts ?

i want to make sure that it uses my rigidbody for movement.

thank you


Well ive just found the aibase, how do i acces those values from it ? I Mean there is no script attached to my agent, how can i read out the velocity ?

Thank you for your time.



If you use one of the built-in movement scripts (AIPath/AILerp/RichAI) then you can read the velocity simply using

var ai = GetComponent<AIPath>(); // For example

More generally it is

var ai = GetComponent<IAstarAI>();

IAstarAI is an interface which all movement scripts implement.

When using a rigidbody, the movement is done using MovePosition. I don’t think the rigidbody actually gets a velocity from that.


Hello thank you aron, it works.

Iam pretty new to c# coding it was new for me that i acces another script which holds the data.

How can i apply a knockback to the agent when it gets hit ? Via PointEffectors or how would you approach this ?



I would use the ai.Move function in a coroutine with a decreasing amount of movement every frame. Alternatively you could modify the velocity of the agent (though I believe you need to subclass the AIPath class for that as it is a protected field).


hello aron, sorry for the late reply but i just started today with the knockbackscript for my enemies.

It works with AI.move, thanks for that! but it doesnt consider collisions. Iam pushing my enemies through walls.

How would you prevent that ?

thank you! Loving your solution so far :slight_smile:



If you use say a CharacterCollider on the agent I think it should use collisions. Alternatively you could enable the ‘Constraint To Inside Graph’ toggle on the AIPath script which will prevent it from moving outside the graph.