- Home /
Simple move script
I consider myself experienced with Unity somewhat, but lately I have been working on other stuff and I'm super rusty. Why isn't this simple move script working? I dont understand.
enter code here
var forwardSpeed : float = 5;
var strafeSpeed : float = 2;
static var moveX : float = 0;
static var moveZ : float = 0;
private var moveDirection : Vector3 = Vector3.zero;
function Start () {
}
function Update () {
var controller : CharacterController = transform.GetComponent(CharacterController);
if(controller.isGrounded) {
moveX = Input.GetAxis("Horizontal") strafeSpeed; moveZ = Input.GetAxis("Vertical") forwardSpeed;
moveDirection = Vector3(moveX, 0, moveZ); moveDirection = transform.TransformDirection(moveDirection);
}
controller.Move(moveDirection * Time.deltaTime);
}