QuickTurn with NavMeshAgent

vau.ceh

New member
Hello:)

I have tried to rewrite the QuickTurn script so that I can use it with a NavMeshAgent. (Third Person Movement Point Click) But now I have the problem that it turns multiple times. I am not sure why it is doing this. Since the RawInput is zero, I just calculated the angle of the next steering target (of the NavMeshAgent) and the Character.Forward Vector to return True in the CanStartAbility if the angle is greater than 150. Do I need to turn off the NavMeshAgentMovement somehow?

the input of the destination is simply done with
navMeshAgentMovement.SetDestination(hitNav.position);


ezgif-4-17b1d3d561.gif


public override bool CanStartAbility() { // if (!base.CanStartAbility()) // { // return false; // } // Don't start the ability if the input magnitude is below the threshold. if (m_CharacterLocomotion.InputVector.sqrMagnitude < m_MinInputSqrMagnitude) { return false; } var steeringDir = (navMeshAgentMovement.SteeringTarget - m_CharacterLocomotion.transform.position) .normalized; float angle = Vector3.Angle(m_CharacterLocomotion.transform.forward.normalized, steeringDir); Debug.DrawRay(m_CharacterLocomotion.transform.position, finishedMovement, Color.yellow); Debug.DrawRay(m_CharacterLocomotion.transform.position, m_CharacterLocomotion.Velocity, Color.blue); if (angle < 150) return false; return true; }


protected override void AbilityStarted() { if (Mathf.Abs(m_CharacterLocomotion.InputVector.x) > m_SpeedChangeThreshold || Mathf.Abs(m_CharacterLocomotion.InputVector.y) > m_SpeedChangeThreshold) { m_StateIndex = 1; } else { m_StateIndex = 0; } IsStarted = true; m_EventStop = false; m_CharacterLocomotion.ForceRootMotionRotation = true; base.AbilityStarted(); }
 
Last edited:
An event should be fired after the quick turn is complete - you should be able to use that event to reset your parameters and prevent the ability from starting multiple times.
 
the animation is only executed once, I think the rotation comes from somewhere else.

However, I have now tried to block the CanStartAbility() after the first execution - the result remains the same.
 
A good way to debug this would be to place a log within the UpdateRotation method of the CharacterLocomotion class to see what rotations it is receiving. This will then allow you to follow the stack up to see what is causing the rotation.
 
Do you use root motion for your animation, and is root motion enabled on the ability? Otherwise the character would turn, but the root would stay still. After the animation the character would flip back into the starting position, and then turn again to follow the new direction.
 
Top