Camera spinning and error/bug

MissingComponentException: There is no ‘NavMeshAgent’ attached to the “Character_Knights_Soldier_01” game object, but a script is trying to access it.
You probably need to add a NavMeshAgent to the game object “Character_Knights_Soldier_01”. Or your script needs to check if the component is attached before using it.

I get this even tough i have NavMeshAgent eqquiped…

UnityEngine.AI.NavMeshAgent.get_velocity () <0x246200c6ae0 + 0x0006a> in <1373a79cfa3d4781b83f94804a190d68>:0
RPG.Movement.Mover.UpdateAnimator () (at Assets/Scripts/Movement/Mover.cs:43)
RPG.Movement.Mover.Update () (at Assets/Scripts/Movement/Mover.cs:21)

Mover script:
using RPG.Core;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.AI;

namespace RPG.Movement
public class Mover : MonoBehaviour, IAction
[SerializeField] Transform target;

    NavMeshAgent NavMeshAgent;

    private void Start() {
        NavMeshAgent = GetComponent<NavMeshAgent>();

    void Update()

    public void StartMoveAction(Vector3 destination)

    public void MoveTo(Vector3 destination)
        NavMeshAgent.destination = destination;
        NavMeshAgent.isStopped = false;

    public void Cancel()
        NavMeshAgent.isStopped = true;

    private void UpdateAnimator()
        Vector3 velocity = NavMeshAgent.velocity;
        Vector3 localVelocity = transform.InverseTransformDirection(velocity);
        float speed = localVelocity.z;
        GetComponent<Animator>().SetFloat("forwardSpeed", speed);


Hello there, probably your script and the navmesh component are not attached into the same object, because, when you use the ‘GetComponent()’ it’s trying to literally get any existing component in the current object and not within the hierarchy, it’s like when you try to get the rigidbody to evaluate his velocity, something like this:

// Game Object --> Rigidbody component attached into it, then...
Rigidbody rb;
rb = GetComponent<Rigidbody>();
rb.velocity =;
// and so on...

In fact, the method that gets any component never miss, just when what is searching does not exist where suppose to be, cheers.

hi thanks it helped… i noticed i had put the navmehsagent for both prefab and object… so unity wasnt happy with that… but when i removed it from prefab it worked and no error message came.
must be amateur mistake i made :smiley: i have made plenty of them