Got this. But I can't just leave it like this

It is so close to being a playable game. Quick, How can I jump from level to level, when I get close to the sphere? I tried to follow this tutorial:

https://www.youtube.com/watch?v=izl5VUm2Frk

I am using Unity 5.5.2f1 personal.

In mono develop, there does not seem to be the SceneManager library.

Can anyone please help?

Thank you.

Hi, are you adding the reference to the top of the code file?

are you getting any other errors?

I kind of have my script worked out now:Preformatted textusing System;
using UnityEngine;
using UnityEngine.SceneManagement;

public class LoadLevel : MonoBehaviour

{

public String LevelToLoad;

void OnTriggerEnter (Collider other)
{
	if (other.CompareTag("Player"))
		{

	        SceneManager.LoadScene ( LevelToLoad );
		}	
}

}

I have no errors and I was able to drop this script onto a cube, as my trigger object. The game runs and loads Level 1. Nothing happens when I enter the trigger. :frowning: I put the string “Assets\Level 2 Jump the box” into the script component, in the Unity editor. I also tried: “Level 2 Jump the box” but nothing.

just try for your string just the level name without assets, so enter the string as Level 2.

as long as the level is in your build settings unity will find it based on the name in the list.

In my case I actually did name my level 2 (Scene 2) as “Level 2 Jump the box”. I will try to simplify it and try again, but I thought that I was very careful with the String. I know that it’s critical to match every symbol, and that it’s case sensitive.

When I get to my computer I will show you how I tackle incremental level changes and see if that helps you.

@James_McLain1

In your OnTriggerEnter method, within the if statement, can you add this line of code:

print("Player entered trigger");

Just want to confirm that the trigger is detecting the player entering the trigger.

If you are not getting this print statement, there could be a few things to resolve the problem:

Check the name of the tag on your player.
Make sure you have IsTrigger checked
Could even try if (other.gameObject.tag == "Player")

1 Like

Privacy & Terms