This question was
closed May 28, 2018 at 08:57 AM by
no00ob for the following reason:
The question is answered, right answer was accepted
How can I deal with eulers
I want to limit this rotations amount to left and right (it's a steering wheel), but the problem is that when it rotates to the left, since its zero at the center when it starts, its already under 310, so it will do weird stuff, if there was a way I could make the default be like 180 this would work but it will rotate the object to be completely wrong if I'd do it manually for an example.
void Update()
{
Debug.Log(wheel.transform.localEulerAngles.y);
if (rotations == 0)
{
wheel.transform.localRotation = defaultRotation;
}
if (wheel.transform.localEulerAngles.y >= 55)
{
if (Input.GetKey(KeyCode.D))
{
wheel.transform.localEulerAngles = new Vector3(0, 55, 0);
}
}
else if (wheel.transform.localEulerAngles.y <= 310)
{
if (Input.GetKey(KeyCode.A))
{
wheel.transform.localEulerAngles = new Vector3(0, 310, 0);
}
}
}
Edit: So I did this (code down below) it actually works only thing is it teleports to the limit if I rotate it to the left, but to be honest, this was already so big pain so I dont care lmao
void Update()
{
Vector3 vector = new Vector3(0, 310, 0);
Debug.Log(wheel.transform.localEulerAngles.y);
if (rotations == 0)
{
wheel.transform.localRotation = defaultRotation;
}
if (wheel.transform.localEulerAngles.y <= 310)
{
if (Input.GetKey(KeyCode.A))
{
wheel.transform.localEulerAngles = new Vector3(0, 310, 0);
}
}
if (wheel.transform.localEulerAngles.y >= 55)
{
if (Input.GetKey(KeyCode.D))
{
wheel.transform.localEulerAngles = new Vector3(0, 55, 0);
}
}
}
Comment
Follow this Question
Related Questions
Why isn't my steering wheel working? 0 Answers
Rotation problem 0 Answers