Support Forum

How do I rotate the AIPath agent from another script?

Is there any way I can set the rotation directly from another script or would it be best to disable rotation on the AIPath and use custom rotation from the external script only?

Hi

There are several ways.
You can set ai.rotation.

You can hide the AI’s own rotation using ai.updateRotation = false. See https://arongranberg.com/astar/docs/aibase.html#updateRotation

You can disable the AIs own rotation code using ai.enableRotation = false. See https://arongranberg.com/astar/docs/aibase.html#enableRotation. This will make it keep track of its own rotation, but it will not actually assign it to the Transform.

You can control the agent’s movement yourself and make it use your rotation code. See https://arongranberg.com/astar/docs/iastarai.html#MovementUpdate