Hi all! For my Character Controller script, I’m making it work with both keyboard and a joystick controller. The rotation with the keys are okay, but it kinda SAPS when going the opposite direction. This is highly noticeable when using the joystick. It’s almost as if the player is really sensitive to the stick rotation, and if the stick is pushed just a bit, the player responds to it.
I’d like there to be a little less sensitivity when using the joystick and to have a smoother rotation. This code snippet controls the rotation. Is there something I can do to make the player rotation smooth?
Control.js
var forward : Vector3 = Camera.main.transform.TransformDirection(Vector3.forward);
forward.y = 0;
forward = forward.normalized;
var right : Vector3 = Vector3(forward.z, 0, -forward.x);
var vertical : float = Input.GetAxis("Vertical");
var horizontal : float = Input.GetAxis("Horizontal");
var targetDirection : Vector3 = horizontal * right + vertical * forward;
targetDirection *= moveSpeed;
moveDirection.x = targetDirection.x;
moveDirection.z = targetDirection.z;
if(targetDirection != Vector3.zero){
var rotation0 = transform.rotation;
rotation0.SetLookRotation(new Vector3(moveDirection.x,0,moveDirection.z) * Time.deltaTime / 0.000005);
transform.localRotation = rotation0;
}
if(canMove)
controller.Move(moveDirection * Time.deltaTime);