Scene Transition Edgecase Error and Solve(?) (2D RPG)

For the generic singleton class lecture when transitioning the player from scene 1 to 2 I was getting a pretty consistent error.

image

If your player object is spawning under the canopy I think it might try to trigger before it is loaded. adding the below if statement solved the issue on my end

if (tilemap.isActiveAndEnabled)
{
StartCoroutine(FadeRoutine(tilemap, fadeTime, tilemap.color.a, 1));
}

6 Likes

I’ll have to look into this as not sure i had this bug but that being said i dont think my player spawns under the canopy.
@Stephen_Hubbard

I have the exact same error.

Thanks

I still havent hit on an exact solution to this but the obvious one is not to have the player spawning under the canopy and that i think if probably the best solution.
The other solution i thought of was having the canopy be set to full opacity on the scene load and then having it fade when the player loads in but that was a tricky work around and i think it would look a bit strange.

Often playing these games the player does not spawn under the canopy so i think that is the way they have done it (Check out Zelda which was the inspiration for this course)

Hope this helps and sorry it took so long to get back to you on this

no worries! just adding in the above if statement that essentially just delayed the coroutine start until the tilemap was active fixed it on my end!

Thanks for looking into it further though! :slight_smile:

1 Like

To ensure it does fire, I added a form of this check to the Coroutine

while(!tilemap.isActiveAndEnabled)
{
      yield return null;
}
//remainder of the coroutine.
1 Like

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

Privacy & Terms