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);
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);
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: