NavMesh Agents spawn in suuuper weird

I’ve been trying to figure this out for a very long time now. Like, weeks. Anyways, the issue I’m running into is when I load a small scene with an NPC using a NavMesh component on top of a NavMesh surface, the NPC gets totally messed up. This ONLY happens in builds of the game, too. This does not happen within the Unity inspector. Here are the things affected in the NPC:

  1. The spawn location of the NPC is completely off, and seemingly random. It always spawns off of the map and way off in the distance, too.
  2. The health is somehow affected by this, because the NPC spawns in with only 100 health compared to its normal amount.
  3. The AI Conversant component on the character changes its dialogue to the last dialogue I had open, regardless of whom it was with (could have been a completely different person in a different scene).

I’m completely lost, and I have no idea where to start when it comes to fixing this issue. I’ve already tried raising the character up a little bit above the NavMesh surface, but that didn’t seem to have an effect. I’ve also already figured out that I could just warp the NPC back to its intended location, and that’s fine, but the health being changed is weird, and the dialogue is the biggest issue with this because it prevents me from progressing in the game. Any ideas on how this could work?

1 Like

So… I ended up brute forcing this into working. I still have no idea what’s causing this issue, but I did find a way to make it work. In Health.cs, I added a boolean to be modified in the inspector for it to know whether or not it should have full health when the scene loads. Thankfully for me, all of the characters having this issue are non-killable, so it’s fine to set it to full health every time the scene loads.

Also, in AIConversant.cs, I added a new Dialogue variable in Awake() to grab the current dialogue that it was set to in the inspector, then in Start(), I set the currentDialogue to the one that was grabbed in Awake(). Not sure how it worked, but it did.

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

Privacy & Terms