Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public bool trigger;
- public string escenaFinal; //nombre de la escena
- public Vector3 coord;
- void Start(){
- }
- void OnTriggerEnter(Collider other) {
- if (other.tag == "Player") {
- trigger = true; //Trigger true
- }
- }
- void OnTriggerExit(Collider other){
- if (other.tag == "Player") { //Sale del trigger falso
- trigger = false;
- }
- }
- void Update(){
- }
- void OnGUI(){
- if (trigger) {
- GUI.Box (new Rect (0, 60, 200, 25), "Presiona K"); //Estamos en trigger
- if(Input.GetKeyDown(KeyCode.K)){ //Si está dentro del Trigger y pulsa la letra K
- GameObject.FindGameObjectWithTag("Player").transform.position = coord;
- SceneManager.LoadScene(escenaFinal); //Cargamos la escena
- GameObject.FindGameObjectWithTag("Player").transform.position = coord;
- }
- }
- }
Add Comment
Please, Sign In to add comment