Change screen when player touches GameObject

I would ask how to do the first person controler, if touches a GameObject, then the game automaticly change scene.
Thank you in advance.

Do you mean change the scene or change something on the screen? Or something else?

Thank you for your answer! Sorry for the mistake of mirwriting scene as screen. Yes, as you said, I would ask how to do the first person controler, if touches a GameObject, then the game automaticly change scene.

maybe the gameobject has a collider with “isTrigger” set, and you implement OnTriggerEnter.
Inside that, use this: Unity - Scripting API: SceneManagement.SceneManager.LoadScene
:slight_smile:

How about that?

using UnityEngine.SceneManagement;
using UnityEngine;

public class Teleport : MonoBehaviour
{
    public class ExampleClass : MonoBehaviour
    {
        void OnTriggerEnter(Collider other)
        {
            SceneManager.LoadScene("Screen03", LoadSceneMode.Additive);
        }

    }
}

And after writing the code, how I can run it to the object?

Well, you just want to put that script on the gameobject that you will run into.

Note: If anything else can run into that object, you should do a quick check to compare the tag to ensure that it was the player that ran into [it] before loading the level. If nothing else can run into it (to trigger it), you don’t need to do that. *also, if that’s the case, I think you can remove the “Collider other” portion in the parameters, as well (slight performance boost). Lastly, if the script fails when you remove the Collider other part, just put it back and I’ve mixed that up with Collision lol.

Try it out :slight_smile:

LoadSceneMode.Additive means you’ll be keeping the current scene + adding a new one… all good, if that’s what you intended.