Mercurial > hg > Members > kazuma > JungleforUnity
view Assets/Application/Scripts/Player.cs @ 0:e5ef0342d00b
First commit
author | Kazuma |
---|---|
date | Mon, 07 Nov 2016 00:39:49 +0900 |
parents | |
children | 2dd40b4412e4 |
line wrap: on
line source
using UnityEngine; using System.Collections; public class Player : MonoBehaviour { // Singleton // -------------------------------------- public static Player Instance; private GameObject eye; private CharacterController cc; private Vector3 Direction; // ------------------------------------- private void Start () { if (Instance == null) { Instance = this; } eye = this.transform.FindChild ("Camera").gameObject; cc = this.GetComponent<CharacterController> (); } private void Update () { Gravity (); } public void Move (bool b) { if (b) { Direction += this.transform.forward / 10f; } else { Direction.x = 0; Direction.z = 0; } cc.Move (Direction); } public void EyeMove (Vector3 v3) { eye.transform.Rotate (-v3.x, 0, 0); this.transform.Rotate (0, v3.y, 0); } public void Gravity () { Direction.y = -0.1f; } }