- Home /
Rotate on Z axis
Hello guys! I've problem with Z axis rotating... I've turret that is rotating by pressing z,x buttons, but turret is rotating like:

so, i decide to rotate it on Z axis. Here is code i am using:
 var speed : float = 5; 
 var backspeed : float = -5;
 
 function Update() {
 
 if (Input.GetKey("z")) 
 {
 transform.Rotate( Vector3, 0,speed*Time.deltaTime, 0,Space.Self); 
 } 
 
 if (Input.GetKey("x")) 
 { 
 transform.Rotate( Vector3, 0,backspeed*Time.deltaTime, 0,Space.Self); 
 }
 } 
So thanks for any help :)
Answer by JeffreyD · Feb 16, 2014 at 04:57 PM
I'm using this below to do a simple rotation of a cube.
transform.Rotate (Vector3.up Time.deltaTime 100, Space.World);
So maybe it's the UP in Vector3 that you need. There also seems to be too many arguments.
http://docs.unity3d.com/Documentation/ScriptReference/Transform.Rotate.html
Try...
transform.Rotate( Vector3.up speed Time.deltaTime, Space.Self);
OR
transform.Rotate(0, 0, speed*Time.deltaTime, Space.Self);
I'm not clear on the use of Space.Self v.s. Space.World. I guess you can play with each to see which give you the effect you want.
Answer by Epic_PotatoGuy · Aug 18, 2017 at 04:54 PM
use transform.Rotate (new Vector3 (0, 0, 20) * time.deltaTime);
Your answer
 
 
             Follow this Question
Related Questions
How can I rotate a tank's turret back to the starting turret position? 2 Answers
question about turret on tank 1 Answer
rotating a tank turret while the tank is rotating 3 Answers
Rotating turret floats off tank in a sideways circle. Cannon floats out of turret when rotating up. 0 Answers
Lock rotation of object 4 Answers
 koobas.hobune.stream
koobas.hobune.stream 
                       
                
                       
			     
			 
                