Rotate to a specific angle on one axis
I'm trying to program an object to rotate to a joystick input (DPad which counts as a joystick).
I've tried using euler angles but only x works sort of? (x, y, z) the x rotates up and down but it flips the object and sometimes jitters back and forth even though I'm not using time and the input isn't changing (only happens on the up input). y rotates on the z axis and z doesn't stop rotating on the z axis. It's driving me insane.
Currently I'm using:
Dpad.eulerAngles = new Vector3(startRotation.eulerAngles.x + (MAX_TILT * -dir.y), startRotation.eulerAngles.y + (MAX_TILT * -dir.x), Dpad.eulerAngles.z);
I've tried using Dpad.rotation, Quaternion.Slerp, localrotation. eulerangles is the only one that got even close to what I'm trying to do, but it only barely works.
dir is a vector2 holding the dpad axis input (-1, 0, or 1). MAX_TILT is the angle (3 in this case). startRotation is the starting rotation of the DPad object.
I'm so confused. Is the model's transform messed up?
I've gotten the jittering to stop with this code before the previous one.
Dpad.rotation = startRotation;
Answer by miscanadian · Jun 14, 2018 at 05:07 PM
Dpad.rotation = startRotation;
Vector3 vec = new Vector3((MAX_TILT * -dir.y), (MAX_TILT * -dir.x), 0);
Dpad.Rotate(vec);
Nevermind I got it. I was over thinking.
Your answer
Follow this Question
Related Questions
Help with suns rotation 0 Answers
Rotating on other axis 1 Answer
,rotate object to match another object on its local 3 axis 1 Answer
Rotate an Object while moving forward using empty gameObject 0 Answers
how to get object rotation? 1 Answer