Hey guys I am trying to take the jump into Quaternians and I finally got this script to rotate nice and smooth, my problem is that after the input ( X Axis on a gamepad joystick) is released the player rotates back.
void FixedUpdate ()
{ //Inputs
// forward
if (Input.GetButton ("A"))
boardbody.AddRelativeForce (transform.forward * moveSpeed);
// slowdown
if (Input.GetButton ("B"))
boardbody.AddRelativeForce (-transform.forward * (moveSpeed / 2));
// rotation
float rotateAroundX = Input.GetAxis ("LeftStickX") * rotateSpeed;
Quaternion rotation = Quaternion.Euler (0, rotateAroundX, 0);
transform.rotation = Quaternion.Lerp (transform.rotation, rotation, Time.deltaTime);
I think I need to write a new Vector 3 but I can’t figure it out.
Another thought is that I haven’t set up the camera to rotate and follow the player yet. Is it possible that would solve this problem?
Any help will be greatly appreciated and I’m sorry to bug you guys!