Rotating Models in Unity

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.

more ▼

asked Apr 03, 2011 at 03:13 PM

avatar image

user-8564 (google)
1 7 6 6

(comments are locked)
10|3000 characters needed characters left

2 answers: sort voted first

Want to rotate the model in the Z axis?

var rotateSpeed = 25.0;

transform.eulerAngles.z += rotateSpeed * Time.deltaTime;

more ▼

answered Apr 03, 2011 at 03:18 PM

avatar image

6.6k 127 131 175

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?

Apr 03, 2011 at 03:53 PM user-8564 (google)

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.

Apr 03, 2011 at 04:54 PM OrangeLightning
(comments are locked)
10|3000 characters needed characters left

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.

more ▼

answered Apr 03, 2011 at 03:52 PM

avatar image

2.7k 37 36 67

(comments are locked)
10|3000 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here



Answers and Comments



asked: Apr 03, 2011 at 03:13 PM

Seen: 1426 times

Last Updated: Apr 03, 2011 at 03:13 PM