Hi for some reason even though from what I gather my code is almost the same as Ricks (which Ill share soon) and I used the same speed settings in this lecture. I’ve set the patrol speed fraction to 0.2 the same as Rick, but for some reason, the enemy is doing the humanoid run rather than walking.
I’ve looked in the animator blend tree to see the forward s value and it = 1.199798 which goes above the 1 value this is why the humonoidRun animation is being activated.
Looking at the enemy’s navmesh his speed is only 1.2 .
This is my code for setting the animation speed:
void UpdateAnimator()
{
Vector3 currentVelocity = _navMeshAgent.velocity;
Vector3 localVelocity = transform.InverseTransformDirection(currentVelocity);
float speed = localVelocity.z;
_animator.SetFloat("forwardSpeed", speed);
}
PatrolBehaviour method in AIController.cs:
private void PatrolBehaviour()
{
Vector3 nextPositioin = _guardPosition;
if (_patrolPath !=null)
{
if (AtWaypoint())
{
_timeAtWaypoint = 0;
CycleWaypoint();
}
nextPositioin = GetCurrentWaypoint();
}
if (_timeAtWaypoint > _waypointDwellTime)
{
_mover.StartMoveAction(nextPositioin, _patrolSpeedFraction);
}
}
I’ve set the maxSpeed to 6