Rotation changes in an unexpected way Help NEEDED
I have been trying to write a simple code to change the rotation of an object so It looks at my mouse pointer. I would have to say I have seen plenty of people write this and make great examples that work but for the life of my I cant get it to work myself.
After doing some trouble shooting I found that the final line of code was the issue. I can write this line numerous ways but it always gets me the same result. So i changed the code to a static variable (0,0,0) which is what the current rotation of the object is set as so it shouldn't do anything however..... the final line to changes the rotation to (270.7067,0,0) when the code should do nothing but keep the rotation the exact same spot as the current location.
objectX is a quad and a child of another object. The rotation is set to 0,0,0 at the start. The parent objects rotation is (90,0,0) not that I think that matters but what do I know I cant set an objects Rotation.
objectX.transform.rotation = new Vector3 (0,0,0); // This makes it (270.7067,0,0) objectX.transform.rotation = quaternion.euler (0,0,0); // This makes it (270.7067,0,0) objextX.transform.eularAngles = (0,0,0); // this makes it (270.7067,0,0) objectX.transform.rotation = new Vector3 (objectX.x, objectX.y, objectX.z); // This makes it (270.7067,0,0)
Maybe somebody can explain what I am doing wrong
Answer by Zivisx · Jan 12, 2016 at 07:40 PM
I figured it out I believe. Like my previous post said it was a child of an object so the natural rotation of my object when it had no parent was 90,0,0 so I simply made an offset variable in my code and used that to offset the Y making it return to its "default position" . I hope that helps somebody else that has an odd-job rotation problem.
objectX.transform.rotation = quaternion.euler (90,lookAngle,0);
Your answer
Follow this Question
Related Questions
How to set a max rotation angle 1 Answer
Rotation smoothing 0 Answers
Child Object Rotation interpolation problem, 0 Answers
How can I set rotation properly? 0 Answers