Animation blend tree isn't matching movement speed

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

This is likely a function of the threshold settings in your Locomotion Blend Tree.

Here’s what Rick has setup, which is equal to the Z movement in each of the animations. You can automate this if you’re using different animations by selecting Z Movement in the Compute Threshholds drop down.

image

1 Like

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.

Privacy & Terms