Player having the shakes

I had the same issue and what helped for me was setting the NavMesh’s Stopping Distance property to some value (about 0.5).

When Brian wrote in [RPG course lecture 37 - Player Shaking when approaching the Enemy - #4 by Brian_Trotter]:

You might check the distance to the target (GetComponent<NavMeshAgent>().remainingDistance ) and compare it to an acceptance radius. Something smaller than the attack range, but larger than the NavMeshAgent’s radius.

I quite didn’t get where this should be applied to, though…

That would go in Mover’s Update() method.

So…?

    public class Mover : MonoBehaviour, IAction
    {
        [Tooltip("Keep this value between the NavMesh agent's radius and the weapon range")]
        [SerializeField] private float acceptanceRadius = 1f;


        void Update()
        {
            if (agent.remainingDistance < acceptanceRadius)
            {
                animator.SetFloat(LOCOMOTION_FORWARD_SPEED, 0);
            }
            UpdateAnimator();
        }

Not really…

And something like

if (remainingDistance > acceptanceRadius)
{
    UpdateAnimator();
}

is even worse.

        {
            if (agent.remainingDistance < acceptanceRadius)
            {
                agent.isStopped=true;
            }
            UpdateAnimator();
        }

Then in Mover.MoveTo()

agent.isStopped=false;

Ah right, so just be calling Cancel() then…
(And because this thread is tagged as “talk” I can’t set that to be the solution…)

Yep. :slight_smile:

1 Like

Privacy & Terms