Advertisement
Guest User

TP_Controller.cs

a guest
Mar 18th, 2014
210
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.04 KB | None | 0 0
  1. using UnityEngine;
  2. using System.Collections;
  3.  
  4. public class TP_Controller : MonoBehaviour {
  5.  
  6.  
  7.     public static CharacterController CharacterController;
  8.     public static TP_Controller Instance;
  9.  
  10.     // Use this for initialization
  11.     void Awake () {
  12.  
  13.         CharacterController = GetComponent ("CharacterController") as CharacterController;
  14.         Instance = this;
  15.         TP_Camera.UseExistingOrCreateNewMainCamera ();
  16.  
  17.     }
  18.    
  19.     // Update is called once per frame
  20.     void Update () {
  21.    
  22.         if (Camera.main == null)
  23.             return;
  24.  
  25.         GetLocomotionInput ();
  26.  
  27.         TP_Motor.Instance.UpdateMotor ();
  28.  
  29.     }
  30.  
  31.     void GetLocomotionInput()
  32.     {
  33.         var deadZone = 0.1f;
  34.  
  35.         TP_Motor.Instance.MoveVector = Vector3.zero;
  36.  
  37.         if (Input.GetAxis ("Vertical") > deadZone || Input.GetAxis ("Vertical") < - deadZone)
  38.                         TP_Motor.Instance.MoveVector += new Vector3 (0,0, Input.GetAxis("Vertical"));
  39.  
  40.         if (Input.GetAxis ("Horizontal") > deadZone || Input.GetAxis ("Horizontal") < - deadZone)
  41.             TP_Motor.Instance.MoveVector += new Vector3 (Input.GetAxis("Horizontal"),0,0);
  42.  
  43.     }
  44.    
  45. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement