AI Navigation Path and rotation on path

The nodes in script canvas for AI navigation seem incredibly limited. One thing I want to do in script canvas is make it such that the Z rotation of the object on a navigation path will follow the path so that the character following the path will match the direction that the path is leading.

I’ve tried several things but apparently I’m just not well practiced enough in spatial/vector math so I can’t ever get the right rotation.

I was wondering if someone could supply a simple example of this or tutorial using script canvas. I would really appreciate it.

And if any Lumberyard devs are reading this if they could take into consideration that their nodes under AI navigation in script canvas seem very limited.


hi! As I’m recall the
bool OnPathFound(LmbrCentral::PathfindRequest::NavigationRequestId requestId, AZStd::shared_ptr<const INavPath> currentPath) override;
can return
AZStd::shared_ptr<const INavPath> m_path;
so keep it as per unit variable in your custom ai class
and then on tick event you can do something like this

	if (m_pathLength - m_distanceRemaining > 0.0)
		m_path->GetPosAlongPath(m_navPosAlongPathBegin, m_pathLength - m_distanceRemaining, true, true);
		m_path->GetPosAlongPath(m_navPosAlongPathEnd, m_pathLength - (m_distanceRemaining - 2.0f), true, true);
	Quat qq = Quat::CreateRotationVDir((m_navPosAlongPathEnd - m_navPosAlongPathBegin).GetNormalized());

	AZ::Quaternion q = LYQuaternionToAZQuaternion(qq);

	//AZ::Quaternion q = AZ::Quaternion::CreateFromVector3(LYVec3ToAZVec3(e).GetNormalized());

working on AI tutorials for script canvas and lua as we speak for the channel, ill keep your issue in mind for sure!