Advertisement
MrsMcLead

openScene

Feb 9th, 2018
405
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.93 KB | None | 0 0
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using UnityEngine.UI;
  5. using UnityEngine.SceneManagement;
  6.  
  7. public class Movement : MonoBehaviour {
  8.     public float speed;
  9.     private Rigidbody rb;
  10.  
  11.  
  12.     // Use this for initialization
  13.     void Start () {
  14.         rb = GetComponent<Rigidbody> ();
  15.  
  16.     }
  17.  
  18.     // Update is called once per frame
  19.     void Update () {
  20.         float moveHorizontal = Input.GetAxis ("Horizontal");
  21.         float moveVertical = Input.GetAxis ("Vertical");
  22.  
  23.         Vector3 movement = new Vector3 (moveHorizontal, 0.0f, moveVertical);
  24.  
  25.         rb.AddForce (movement * speed);
  26.     }
  27.     //---------------------------------
  28.     void OnTriggerEnter(Collider other)
  29.     {
  30.         if (other.gameObject.CompareTag ("Win")) {
  31.             SceneManager.LoadScene ("win", LoadSceneMode.Single);
  32.  
  33.             }
  34.         else if(other.gameObject.CompareTag("Lose")){
  35.             SceneManager.LoadScene ("lose", LoadSceneMode.Single);
  36.         }
  37.     }
  38.     //---------------------------------
  39. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement