AILerp direction

I want movement without acceleration and found another thread where you say to use AILerp instead of AIPath. So I switched to AILerp but cannot find a simple way in that script to get the direction of current movement. In AIPath I just turned the local dir variable into a global one and that worked just fine.

Could something similar be done in AILerp? I need it to set the correct animation direction in 2D.

EDIT: Also, it seems using AILerp, if the AI does not have a destination, instead of standing still they move down/left in a 2D world. Is this something you are aware of? Using AIPath they just stood still.

EDIT 2: It’s also giving me a new error originating from AILerp: “NullReferenceException: No AstarPath object found in the scene. Make sure there is one or do not create paths in Awake”

You can use (ai as IAstarAI).velocity to get the direction it is moving.

(GetComponent<AILerp>() as IAstarAI).velocity

Do you have an AstarPath object in your scene?

1 Like