- Home /
Weird jumpy motion of character in Navigation Fundamentals proect
So I've been going through the Intermediate Fundamentals Game Dev course in Unity Learn, and I got most of the way through the first part, Unity Navigation Fundamentals, when I noticed the player character's movement was very weird and jumpy. When I click on a location, instead of running to that location, the character runs past the location and then teleports back to it—or, if running a longer distance, the character repeatedly teleports backward during the run. (I'd include a video, but I'm not sure how to do that.) If I have the character selected and watch the editor as the game runs, I can see that the NavMeshAgent that the player character is attached to moves as it should (and so does its Capsule Collider component), but the player character model for some reason doesn't stay aligned with it; it runs out of the NavMeshAgent, and then teleports back to it when it stops. I've been trying to follow all of the instructions in the course, and using the same code, so I'm not sure what's wrong.
It seems to have something to do with the animation, because when I disable the script that matches the animation to the motion, the character no longer has that weird, jerky, teleporty movement (though of course the character no longer animates properly). Specifically, here's the script in question:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.AI;
public class NavigationAnimation : MonoBehaviour
{
NavMeshAgent agent;
Animator anim;
// Start is called before the first frame update
void Start()
{
agent = GetComponent<NavMeshAgent>();
anim = GetComponentInChildren<Animator>();
}
// Update is called once per frame
void Update()
{
anim.SetFloat("Forward", agent.velocity.sqrMagnitude);
}
}
If I disable that script, the problem goes away (though, again, the character's run isn't animated)—but that script is very simple and is directly out of the course, so I don't think the script itself is at fault; I think it must be either something with the animator (though I didn't change anything there), or some setting I'm overlooking that I accidentally changed.
Maybe it's a Unity version issue? I had to do a bit of tweaking to get the provided assets working with Unity 2019 at all. They do all seem to be working fine now, though, except for that weird movement issue.
I'd attach a package of my project, but, uh, it's well over a gigabyte in size (the provided Unity Navigation Fundamentals package from the Unity Store includes a lot of models and graphics and is about 2.5 gigabytes). I can attach any specific assets or screenshots if they might help pin down the problem, though. And, if it helps, here's a screenshot of the settings of the character itself:
Your answer
Follow this Question
Related Questions
Changing only vertical speed on NavMeshAgent? 0 Answers
How to move NavMesh Agent by animation? 2 Answers
Navigation with height mesh and Animation 0 Answers
Nav mesh agent position 1 Answer
NavMeshAgent Destination Problem 0 Answers