Soifra

Old PlayerController.cs

Mar 4th, 2017
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.63 KB | None | 0 0
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4.  
  5. public class PlayerController : MonoBehaviour {
  6.  
  7.     public float speed;
  8.  
  9.     private Rigidbody rb;
  10.  
  11.     void Start ()
  12.     {
  13.         rb = GetComponent<Rigidbody> ();
  14.     }
  15.  
  16.     void FixedUpdate ()
  17.     {
  18.         float moveHorizontal = Input.GetAxis ("Horizontal");
  19.         float moveVertical = Input.GetAxis ("Vertical");
  20.  
  21.         Vector3 movement = new Vector3 (moveHorizontal, 0.0f, moveVertical);
  22.  
  23.         rb.AddForce (movement * speed);
  24.     }
  25.     void OnTriggerEnter (Collider other)
  26.     {
  27.         if (other.gameObject.CompareTag ("Pick Up"))
  28.         {
  29.             other.gameObject.SetActive (false);
  30.         }
  31.     }
  32. }
Advertisement
Add Comment
Please, Sign In to add comment