Created
January 11, 2016 20:56
-
-
Save st4rdog/4ed0cb0bca5785f9e15d to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using UnityEngine; | |
using System.Collections; | |
public class PlayerMoveS : MonoBehaviour { | |
[Header("Settings")] | |
public float speed = 10f; | |
// COMPONENTS | |
private CharacterController cc; | |
//============================================ | |
// FUNCTIONS (UNITY) | |
//============================================ | |
void Awake() | |
{ | |
cc = GetComponent<CharacterController>(); | |
} | |
void Update() | |
{ | |
float h = Input.GetAxis("Horizontal"); | |
float v = Input.GetAxis("Vertical"); | |
Vector3 forward = transform.forward * v * speed * Time.deltaTime; | |
Vector3 right = transform.right * h * speed * Time.deltaTime; | |
cc.Move(forward + right); | |
} | |
//============================================ | |
// FUNCTIONS (CUSTOM) | |
//============================================ | |
//============================================ | |
// PROPERTIES | |
//============================================ | |
//============================================ | |
// EVENT RECEIVERS | |
//============================================ | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment