Search Unity

Teletrasport to scene

Discussion in 'Scripting' started by Timoty75, Aug 20, 2017.

  1. Timoty75

    Timoty75

    Joined:
    May 29, 2017
    Posts:
    150
    Hi guys I have a problem: I have to cross my character in a cube so they teleport to another scene ... I tried this script that they suggested but it does not work .. The editor gives me this message: The associated script can not be loaded. Please fix any compiler errors and assign a valid scrip.
    This is the script:
    Using System.Collections;
    Using System.Collections.Generic;
    Using UnityEngine;
    Using UnityEngine.SceneManagement;
    Public class loadRoomScene: MonoBehaviour { Private void OnTriggerEnter (Collider sceneTrigger) {
    // When your Character collides with the collider box If (sceneTrigger.CompareTag ("TagOfTheColliderThatWillTriggerTheLoading")) { SceneManager.LoadScene ("NameOfYourScene", LoadSceneMode.Additive); } } }

    What is that I'm wrong?..Please help Me!!
     
  2. methos5k

    methos5k

    Joined:
    Aug 3, 2015
    Posts:
    8,712
    Please refer to this page when you want to post code on the forums: https://forum.unity3d.com/threads/using-code-tags-properly.143875/

    If your script is written exactly like you posted here, you might be having an issue with the tag and name of the scene. Those are 'placeholder' words where you'd insert the actual name of the tag and scene. Make sure they are correct and matching their appropriate bits.

    Please edit your post using code tags if you need further help, so people can read it :)
     
    Timoty75 likes this.