So Im trying to basically ask my script, if moveDirection, a vector 3.zero variable, is less than 0 on the x axis (if I move left it goes to the minus on the x axis), for now it just has a debug.log, and then move than 0 does the same thing. Heres my full script
var speed = 6.0;
var jumpSpeed = 8.0;
var gravity = 20.0;
private var moveDirection = Vector3.zero;
private var grounded : boolean = false;
function Awake(){
if(networkView.isMine == false){
//If this object doesn't belong to us, disable this script on our end
enabled = false;
}
}
function FixedUpdate() {
if (grounded)
{
// We are grounded, so recalculate movedirection directly from axes
moveDirection = new Vector3(Input.GetAxis("Horizontal"), 0);
moveDirection = transform.TransformDirection(moveDirection);
moveDirection *= speed;
if (Input.GetButton ("Jump"))
{
moveDirection.y = jumpSpeed;
}
}
// Apply gravity
moveDirection.y -= gravity * Time.deltaTime;
// Move the controller
var controller : CharacterController = GetComponent(CharacterController);
var flags = controller.Move(moveDirection * Time.deltaTime);
grounded = (flags & CollisionFlags.CollidedBelow) != 0;
}
function Update(){
Debug.Log(moveDirection);
}
and then what Im trying to do is this
if (moveDirection < (0,-2,0){
Debug.Log ("Left");
}
if (moveDirection > (0,-2,0){
Debug.Log ("Right");
}
Thanks