i need help , for this code this code have latency in build game, 0,5 lag
var speed : float = 6.0;
var jumpSpeed : float = 8.0;
var gravity : float = 20.0;
private var moveDirection : Vector3 = Vector3.zero;
function Update() {
var controller : CharacterController = GetComponent(CharacterController);
if (controller.isGrounded) {
// We are grounded, so recalculate
// move direction directly from axes
moveDirection = Vector3(Input.GetAxis("Horizontal"),0,0);
//moveDirection = transform.TransformDirection(moveDirection);
moveDirection *= speed;
if(moveDirection.sqrMagnitude > 0.1)
transform.rotation = Quaternion.Slerp(transform.rotation,Quaternion.LookRotation(moveDirection),1);
if (Input.GetButton ("Jump")) {
moveDirection.y = jumpSpeed ;
}
}
// Apply gravity
moveDirection.y -= gravity * Time.deltaTime;
// Move the controller
controller.Move(moveDirection * Time.deltaTime);
}
or need code side scrolling
sorry for bad english