diff --git a/Assets/GothicVR/Scripts/Creator/NpcCreator.cs b/Assets/GothicVR/Scripts/Creator/NpcCreator.cs index 33d3c0952..ec7581bd8 100644 --- a/Assets/GothicVR/Scripts/Creator/NpcCreator.cs +++ b/Assets/GothicVR/Scripts/Creator/NpcCreator.cs @@ -115,6 +115,13 @@ private static void SetSpawnPoint(GameObject npcGo, string spawnPoint) { var routineSpawnPointName = npcGo.GetComponent().CurrentRoutine.waypoint; initialSpawnPoint = WayNetHelper.GetWayNetPoint(routineSpawnPointName); + + // Fallback: No WP found? Try one more time with the previous (most likely "earlier") routine waypoint. + if (initialSpawnPoint == null) + { + routineSpawnPointName = npcGo.GetComponent().GetPreviousRoutine().waypoint; + initialSpawnPoint = WayNetHelper.GetWayNetPoint(routineSpawnPointName); + } } else { diff --git a/Assets/GothicVR/Scripts/Npc/Routines/Routine.cs b/Assets/GothicVR/Scripts/Npc/Routines/Routine.cs index ef6d6627d..984b0d769 100644 --- a/Assets/GothicVR/Scripts/Npc/Routines/Routine.cs +++ b/Assets/GothicVR/Scripts/Npc/Routines/Routine.cs @@ -81,5 +81,11 @@ public bool CalculateCurrentRoutine() return changed; } + + public RoutineData GetPreviousRoutine() + { + var currentRoutineIndex = Routines.IndexOf(CurrentRoutine); + return currentRoutineIndex == 0 ? Routines.Last() : Routines[currentRoutineIndex - 1]; + } } }