Weirdest bug regarding new NavMesh

I tried implementing the new Navmesh surface and navmesh agent but I keep having the weirdest bug and I honestly don’t know what might be causing it since the code is exactly the same as the one on the lecture.
While playtesting the enemy ai will enter the chase state but won’t actually move, it’ll stay running in place(Picture A).
However, I noticed that if I enter play mode, while having both the scene and game tabs open at the same time, the enemy ai will work as intended(Picture B).
Not sure if this is a Unity bug or if it’s something I can solve on my end, I’ve tried narrowing it down and all I can do moving forward is separate the scene and game tabs so I can correctly playtest the game.

I added the navmesh surface to the terrain and the navmesh agent to the enemy gameobject, I honestly cannot think of a reason why this would happen. Any ideas on what might be causing it would be greatly appreciated, it’s a little frustrating moving forward and having to separate both tabs on a laptop.


I’m leaning towards Unity Bug… That being said, some versions have been having trouble with simply updating the NavMeshAgent’s Velocity. See if this code helps:

    private void MoveToPlayer(float deltaTime)
    {
        if (stateMachine.Agent.isOnNavMesh)
        {
            stateMachine.Agent.destination = stateMachine.Player.transform.position;

            Move(stateMachine.Agent.desiredVelocity.normalized * stateMachine.MovementSpeed, deltaTime);
        }
        //Setting nextPosition to glue agent to the current position of the player
        stateMachine.Agent.nextPosition = stateMachine.transform.position;
        stateMachine.Agent.velocity = stateMachine.Controller.velocity;
    }
1 Like

That fixed the Agent not sticking to the controller but the split screen bug keeps happening lol
Pretty sure it’s a Unity bug, thanks anyway, Brian!

That, I still have no explanation for. While the Scene view being open does affect things like whether a Renderer detects that it is visible (because technically, the Scene View causes the renderer to render), it shouldn’t affect navigation in the slightest. I’m pretty sure it’s a Unity bug as well. See what happens when you build the game out… that’s the only place it really matters anyways.

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.

Privacy & Terms