Wont stop loading second level on input

Hello guys ! Having a bit of an issue with my code. When I collide on finish it executes to the next level just fine but when I try use it in if(input.getkeydown(keycode.L)) it will load to level 2 and then once I am on level 2 and try to use it again it reloads level 2. I know i’m probably overlooking something here or mayabe unity 2021 has a bug? I only have 2 levels built.

Hi,

Have you already tried to add Debug.Logs to your code to see what is going on during runtime? Maybe the if-conditon gets evaluated to true in level 2. In that case, check your build settings list. Maybe level 2 is assigned to build index 0.

I will give it a shot thank you!

Level 2 is assigned to build index 1 and it reloads that level when I press down L but when I collide with finish it continues the loop and loads level 1 at build index 0

That’s interesting. I’m wondering if level 1 does get loaded right after level 2 for a brief moment before level 2 gets loaded. Since this might happen within less than a second, it is difficult/impossible to see that in the game window. That’s why I asked if you added Debug.Logs to your code.

That is exactly what is happening. It will show in the hierarchy that it’s loading the level and then says level not loaded so I just used the string reference approach and assigned each string to a different alpha input and it’s working fine. Maybe it’s just my build of unity or I’m over looking something. I have a bad tendency of over complicating things lol This is my solution

image

Good job on solving the problem. :slight_smile:

Maybe you could remove all scenes from the Build Settings list and readd them. Sometimes, that list is simply buggy, especially if there is a “deleted” entry in it.


See also:

Thank you for all your help I’ll give it a shot :slight_smile:

It worked! thank you again for everything :slight_smile:

I’m glad I could help. Have a nice weekend! :slight_smile:

Thank you, you have a nice weekend as well :slight_smile:

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

Privacy & Terms