Location Loader issue

I have spotted an issue with the Location Loader where, at some point, an error will cause two locations to be stacked, which results in critical bugs, like having two instances of the Player at the same time.

How to recreate:
This bug was spotted in the currently existing locations of the game: Beach and Forest. If we enter/exit a location multiple times during gameplay, at some point the console will log the error message: «ArgumentOutOfRangeException: Index was out of range. Must be non-negative and less than the size of the collection. Parameter name: index.». After this error occurs, when we exit a location through the respective LocationExit trigger, we will have both the previous and next locations loaded at the same time.

Possible fix:
I’ve noticed that the LocationLoader script loads new scenes before unloading the existing ones, which makes me wonder: shouldn’t this happen reversely? I mean, it makes more sense to unload the existing scenes first, before setting the new ones to load.

Summary:

  • Review the LoadScenes method in LocationLoader.cs.

Thanks for reporting it!
I will link the issue here for rapid access: Location Loader issue · Issue #229 · UnityTechnologies/open-project-1 · GitHub

1 Like

I have India to fix this bug…