Skip to content

Instantly share code, notes, and snippets.

@st4rdog
Created January 11, 2016 20:56
Show Gist options
  • Save st4rdog/4ed0cb0bca5785f9e15d to your computer and use it in GitHub Desktop.
Save st4rdog/4ed0cb0bca5785f9e15d to your computer and use it in GitHub Desktop.
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