Guest User

Untitled

a guest
Jun 19th, 2018
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.83 KB | None | 0 0
  1. public bool trigger;
  2. public string escenaFinal; //nombre de la escena
  3. public Vector3 coord;
  4.  
  5. void Start(){
  6.  
  7. }
  8.  
  9. void OnTriggerEnter(Collider other) {
  10. if (other.tag == "Player") {
  11.  
  12. trigger = true; //Trigger true
  13.  
  14. }
  15. }
  16.  
  17. void OnTriggerExit(Collider other){
  18.  
  19. if (other.tag == "Player") { //Sale del trigger falso
  20.  
  21. trigger = false;
  22.  
  23. }
  24. }
  25.  
  26. void Update(){
  27.  
  28. }
  29.  
  30. void OnGUI(){
  31. if (trigger) {
  32. GUI.Box (new Rect (0, 60, 200, 25), "Presiona K"); //Estamos en trigger
  33. if(Input.GetKeyDown(KeyCode.K)){ //Si está dentro del Trigger y pulsa la letra K
  34. GameObject.FindGameObjectWithTag("Player").transform.position = coord;
  35. SceneManager.LoadScene(escenaFinal); //Cargamos la escena
  36. GameObject.FindGameObjectWithTag("Player").transform.position = coord;
  37. }
  38. }
  39. }
Add Comment
Please, Sign In to add comment