Unty 3D C# Load other scene when bool = true, otherwise perform teleportation as commanded.

Hello everyone,

I got another question I wanted to ask.

I already got a teleport to target location when you exit one, so that is done. But what I want to achieve now is that when you have interacted with some object, that then The bool is set on true, and when you collide with the object this script is attached to you will be send to another scene, otherwise you will just be teleported to the beginning of this scene.

this is the script I assembled :

      using UnityEngine;
      using System.Collections;

         public class Telepiti : MonoBehaviour {
    /// <summary>
/// Here I take the bool of if I am teleported, so that I can prevent spam      porting.
/// Target = the point where I will be teleported to.
/// </summary>
public bool Interacted = false;
public Interacted interact;
public bool teleported = false;
public Telepiti target;

// Use this for initialization
void Start () {

}

// Update is called once per frame
void Update () {

}

void OnTriggerEnter(Collider other)
{
    ///<summary> 
    ///If I am teleported then It will be set to true and I will be teleported to point B
    ///Then It sets the teleport on false AND I will be able to teleport again!
    /// /summary>
    if (other.CompareTag("Player"))
    {
        if (!teleported)
        {
            ///<summary>
            //Teleports me to Location B AND turns me to a chosen degree with quaternion.Euler</summary>
            target.teleported = true; other.gameObject.transform.position = target.gameObject.transform.position;
            other.transform.rotation = Quaternion.Euler(0, 0, 0);
        }
    }
}
/// <summary>
/// This gives me the possibility to teleport
/// </summary>
/// <param name="other"></param>
void OnTriggerExit(Collider other)
{
    if (other.CompareTag("Player"))
    {
        teleported = false;
    }
}
}

Now I have walked into a wall, and I can not get past it.
So what should I do to be able to Teleport to another scene IF the bool is set to true because I interacted with something?
Should I make another void with onCollisionEnter?
I am making an RPG horror game (something like Silent hill.).
I want it to teleport you to another scene IF the bool = true, and if you did not interact with an object and collide with the Telepiti, then you will be teleported to Point B in the same scene.

I just do not know what I should do.

Thank you all again in advance for all your help,
And have a nice day,

Daniel Nowak Janssen

if (other.CompareTag(“Player”))
{
if (potato) {
Application.Load(“MyLevel2”);
}
if (!teleported)
{
target.teleported = true; other.gameObject.transform.position = target.gameObject.transform.position;
other.transform.rotation = Quaternion.Euler(0, 0, 0);
}
}

You could use else if, but it doesn’t matter as the level will be destroyed and it wont continue checking further.