Character doesn't move when I click on things, just glides around

I followed the tutorial carefully this time, it’s probably something obvious I am overlooking in the scripts.
He goes in circles after I click somewhere as well.

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.AI;

public class Mover : MonoBehaviour
{
    [SerializeField] Transform target;

    void Update()
    {
        if (Input.GetMouseButtonDown(0))
        {
            MoveToCursor();
        }
        UpdateAnimator();
    }
        private void MoveToCursor()
        {
            Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);
            RaycastHit hit;
            bool hasHit = Physics.Raycast(ray, out hit);
            if (hasHit)
            {
                GetComponent<UnityEngine.AI.NavMeshAgent>().destination = hit.point;
            }
        }
    private void UpdateAnimator()
    {
        Vector3 velocity = GetComponent<UnityEngine.AI.NavMeshAgent>().velocity;
        Vector3 localVelocity = transform.InverseTransformDirection(velocity);
        float speed = localVelocity.z;
        GetComponent<Animator>().SetFloat("forwardSpeed", speed);
    }
}

So the character is moving (gliding is moving), but not animating?

Make sure that the float you’ve assigned to your blend tree is named “forwardSpeed”. Remember that case matters, so “forwardSpeed” is not equal to “ForwardSpeed” or “forwardspeed”.

Yes I checked.

There’s also this issue where after I click somewhere, the character goes walking in circles.

When I encounter something like this should I move on in the course or wait for it to be resolved?

I fixed this.

I’d still like to know if it’s worth progressing though. I feel that if I fix every single error it will take too long.

The problem with continuing on once an error has occurred without fixing that error is that you’ll potentially continue along a path that is difficult to unwind…

It’s best to try to find a solution. Have you been to our Discord server at https://discord.gg/gamedevtv? You can ask in the RPG section for assistance on some things if you get stuck and you should often find that there are students there who can help you along. That might speed things up, as sometimes, depending on when a question is asked it can take a day for me to get to it.

I’ve done that, as well as used Reddit and Google. The quality of the replies varies, some people are not helpful or provide misinformation.

Privacy & Terms