I need some help, I am unable to figure out what to change to make this work locally instead of global, this code is from the scripting reference page under CharacterController.move… The transform.TransformDirection is suppose to make it global, I have removed it from script and also tried transform.InverseTransformDirection but to no avail any ideas out there?
#pragma strict
var speed : float = 6.0;
var jumpSpeed : float = 8.0;
var gravity : float = 20.0;
private var moveDirection : Vector3 = Vector3.zero;
function Start () {
}
function Update () {
var controller : CharacterController = GetComponent(CharacterController);
if(controller.isGrounded){
moveDirection = Vector3(Input.GetAxis("Horizontal"),0,Input.GetAxis("Vertical"));
moveDirection = transform.TransformDirection(moveDirection);
moveDirection *= speed;
if(Input.GetButton("Jump")){
moveDirection.y = jumpSpeed;
}
}
moveDirection.y -= gravity * Time.deltaTime;
controller.Move(moveDirection * Time.deltaTime);
}
If there is a way to turn this local please point me out in the right direction.