Advertisement
Guest User

Untitled

a guest
Jul 11th, 2016
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.32 KB | None | 0 0
  1. using UnityEngine;
  2. using System.Collections;
  3. using UnityStandardAssets.Characters.FirstPerson;
  4. using System.Collections.Generic;
  5. using UnityEngine.UI;
  6.  
  7. public class Player : MonoBehaviour {
  8.     public static Player Instance = null;
  9.  
  10.     CharacterController controller;
  11.  
  12.     public float walkSpeed = 6.0F;
  13.     public float runSpeed = 9.0f;
  14.     public float jumpSpeed = 8.0F;
  15.     public float gravity = 20.0F;
  16.     private Vector3 moveDirection = Vector3.zero;
  17.  
  18.     public HandlerPlayerStats HandlerPlayerStats;
  19.  
  20.     public SimpleMouseLook CameraLook;
  21.     public SimpleMouseLook PlayerLook;
  22.  
  23.     void Awake()
  24.     {
  25.         Instance = this;
  26.         controller = GetComponent<CharacterController>();
  27.     }
  28.  
  29.     void Start()
  30.     {
  31.         Init();
  32.     }
  33.  
  34.     private void Init()
  35.     {
  36.         HandlerPlayerStats.Init();
  37.     }
  38.  
  39.     void Update()
  40.     {
  41.         Vector2 axis = GameManager.Instance.GetAxisMove();
  42.  
  43.         if (controller.isGrounded)
  44.         {
  45.  
  46.             moveDirection = new Vector3(axis.x, 0, axis.y);  
  47.             moveDirection = transform.TransformDirection(moveDirection);
  48.         }
  49.  
  50.         moveDirection.y -= gravity * Time.deltaTime;
  51.         controller.Move(moveDirection * Time.deltaTime);
  52.     }
  53.  
  54.     public void AddSatiety(int value)
  55.     {
  56.         //Satiety += value;
  57.     }
  58. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement