Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Bug Location Loader issue

Discussion in 'Open Projects' started by gabagpereira, Nov 26, 2020.

  1. gabagpereira

    gabagpereira

    Joined:
    Jan 21, 2019
    Posts:
    23
    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.

    issue.png

    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.
     
  2. cirocontinisio

    cirocontinisio

    Joined:
    Jun 20, 2016
    Posts:
    884
    gabagpereira likes this.
  3. khushalborana537

    khushalborana537

    Joined:
    Dec 2, 2020
    Posts:
    4