Ok i am new to Unity so this may seem like a stupid question:
I have bought some fbx models with whicj i attend to make a 2D game. To be able to use hte models the way i want, i have to rotate them 270 deg in the x-axis. From that i point on during the game i want the model to rotate in the z-axis to simulate a steering movement. But when I do it (I use : gameObject.transform.Rotate(0,0,-Time.deltaTime*radialVelocity, Space.World), the effect i get is not what i want. When i rotate the fbx either from the iterface or using code w.r.t it self i get even stranger results. Basically my question is that after i rotate the model in the x-axis how to i make rotate on its z-axis without causing it to rotate in any other axes.
Answer by OrangeLightning
Apr 03, 2011 at 03:18 PM
Want to rotate the model in the Z axis?
var rotateSpeed = 25.0;
transform.eulerAngles.z += rotateSpeed * Time.deltaTime;
If i do this my model will rotate in its y-axis (remember the model is already rotated in x). If i do transform.eulerAngles.y ... , it will again in the y axis. Strange e? If i try to rotate in the x :transform.eulerAngles.x ... ,it will rotate in the x-axis as it should. Its only the z-axis that has a problem. Note that if i dont rotate the model (just drag it in the hierarchy view ) and i rotate through code usuing transform.eulerAngles.y ...in the y-axis , i get the effect i want . Why is it trhat i get this problem with the z?
I am sorry that my question did not aid you, and I really have no clue how I can further help you besides telling you that it sounds like your x,y and z axis is messed up.
Answer by AngryOldMan
Apr 03, 2011 at 03:52 PM
in your 3d modelling software you need to alter the pivot point of the object BEFORE you animate and/or import it into unity. I've had the exact same problems, seen it loads of times, and loads of people have asked this same question, next time try looking for the answer via google or the archives of this site instead of polluting it with already overly asked questions.
Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.
The best place to ask and answer questions about development with Unity.
To help users navigate the site we have posted a user guide.
If you are a new user, check out our FAQ for more information.
If you are a moderator, see our Moderator Guidelines page.
We are making improvements to UA, see the list of changes.
For troubleshooting common problems with Unity 5.x Editor (including Win 10).
Answers and Comments
No one has followed this question yet.
Flip over an object (smooth transition)
Current Rotation into Direction Vector for LookRotation
Raycast Rotation on Steering Wheel
transform.rotation.z gives different value than expected
"Free" rotation about a sphere