Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using UnityEngine;
- using System.Collections;
- public class TP_Controller : MonoBehaviour {
- public static CharacterController CharacterController;
- public static TP_Controller Instance;
- // Use this for initialization
- void Awake () {
- CharacterController = GetComponent ("CharacterController") as CharacterController;
- Instance = this;
- TP_Camera.UseExistingOrCreateNewMainCamera ();
- }
- // Update is called once per frame
- void Update () {
- if (Camera.main == null)
- return;
- GetLocomotionInput ();
- TP_Motor.Instance.UpdateMotor ();
- }
- void GetLocomotionInput()
- {
- var deadZone = 0.1f;
- TP_Motor.Instance.MoveVector = Vector3.zero;
- if (Input.GetAxis ("Vertical") > deadZone || Input.GetAxis ("Vertical") < - deadZone)
- TP_Motor.Instance.MoveVector += new Vector3 (0,0, Input.GetAxis("Vertical"));
- if (Input.GetAxis ("Horizontal") > deadZone || Input.GetAxis ("Horizontal") < - deadZone)
- TP_Motor.Instance.MoveVector += new Vector3 (Input.GetAxis("Horizontal"),0,0);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement