- Home /
Question by
PlayCreatively · Mar 15, 2019 at 08:26 PM ·
rotationconverteulerdegreesaddrelativetorque
Is there a way to convert a euler vector from 0 to 360 --> -90 to 90?
I'm trying to totate the player and it works when rotating by positive dirInput
but when I get negative the player spasms out.
I'm guessing the problem is transform.localEulerAngles
gives me 0 to 360 instead of -90 to 90. How can I convert transform.localEulerAngles
?
The code:
Vector3 dirInput = new Vector3(Input.GetAxis("Vertical"), Input.GetAxis("Horizontal"));
dirInput.x *= 15f;
dirInput.y *= 90f;
rb.AddRelativeTorque((-transform.localEulerAngles + dirInput) * rotSpeed, ForceMode.Impulse);
Comment