Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions Assets/GothicVR/Scripts/Creator/NpcCreator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,13 @@ private static void SetSpawnPoint(GameObject npcGo, string spawnPoint)
{
var routineSpawnPointName = npcGo.GetComponent<Routine>().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<Routine>().GetPreviousRoutine().waypoint;
initialSpawnPoint = WayNetHelper.GetWayNetPoint(routineSpawnPointName);
}
}
else
{
Expand Down
6 changes: 6 additions & 0 deletions Assets/GothicVR/Scripts/Npc/Routines/Routine.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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];
}
}
}