- Home /
Eurlar angles to Quaternion help
I want to use Quaternion because that way I can learn them but I am a bit lost on which one to use and how to use it. I have been looking at the reference pages but still a bit over my head.
Ok so what I want to do is to translate my current code into one that use Quaternion.
This is what I have, what it does is when the left or right trigger on a xbox pad is pressed it turns a guy and tilts him at the same time. I want to replace the tilt with the Quaternion because that way the player wont flip over and over on some rotational inputs.
if(Input.GetAxisRaw("LT") > 0 )
{
transform.Rotate(-Vector3.up * Time.deltaTime * (Input.GetAxisRaw("LT")) * turnSpeed, Space.World);
this.rigidbody.drag = .9;
if(playerLRot < 25 || playerLRot > 340)
{
this.transform.Rotate(Vector3.forward * Time.deltaTime * 15);
playerLRot = this.transform.eulerAngles.z;
}
}else if(Input.GetAxisRaw("RT") > 0 )
{
transform.Rotate(Vector3.up * Time.deltaTime * (Input.GetAxisRaw("RT")) * turnSpeed, Space.World);
this.rigidbody.drag = .9;
if(playerRRot > 340 || playerRRot < 25)
{
this.transform.Rotate(-Vector3.forward * Time.deltaTime * 15);
playerRRot = this.transform.eulerAngles.z;
}
}
//player is not turning
if(!Input.GetAxisRaw("LT"))
{
if(playerLRot > 0)
{
this.transform.Rotate(-Vector3.forward * Time.deltaTime * 60);
playerLRot = this.transform.eulerAngles.z;
}
}
if(!Input.GetAxisRaw("RT"))
{
if(playerRRot >= 340 && playerRRot != 0)
{
this.transform.Rotate(Vector3.forward * Time.deltaTime * 60);
playerRRot = this.transform.eulerAngles.z;
}
}
thanks for any help with this
Your answer
Follow this Question
Related Questions
Smooth rotation in 90° increments 0 Answers
unwanted rotation on the y and z axes 1 Answer
Fixing the rotation around a particular axis using Quaternions? 2 Answers
trouble with Quaternion rotation in 360 axis degree 0 Answers
Apply game object rotation using relative VR controller rotation? 2 Answers