- Home /
z-axis Rotation
Okay; so I was looking at the unity script reference pages and I wanted to know how I would rotate an object on the z axis. I'm trying to achieve a sideways rotation (is roll a better word?) for a first person maze where you can rotate the level itself. the problem is that the C & V keys result in the object spinning as if I was using the mouse to spin myself in a circle.
var Player : Transform; var RotateSpeed = 20;
function Update () {
if (Input.GetKey ("z")) // spin the player around the world origin at 'RotateSpeed' degrees/second. transform.RotateAround (Player.position, Vector3.right, RotateSpeed Time.deltaTime); if (Input.GetKey ("x")) transform.RotateAround (Player.position, Vector3.left, RotateSpeed Time.deltaTime);
if (Input.GetKey ("c")) transform.RotateAround (Player.position, Vector3.down, RotateSpeed * Time.deltaTime);
if (Input.GetKey ("v")) transform.RotateAround (Player.position, Vector3.up,RotateSpeed * Time.deltaTime);
}
I'd suggest editing your post and placing your code correctly between the 'code' tags so people will be able to read your code easier, and be more willing to help :)
=D He did it... O$$anonymous$$G, +1 to both of you! Haha... Checking the problem though =) 1 sec.
So... Did you want the level to like... $$anonymous$$ind do a "Barrel Roll" over you? So like, the level will be upside down? Or am I reading this wrong? =)
Oh, and if you do... the ZX keys are doing that for me...
Answer by poncho · Mar 29, 2011 at 02:15 PM
you can use transform.Rotate( Vector3 ) i use it to rotate objects so if your object is the whole map, i bet it will work
Unfortunately, I can't do it that way; It cause all sorts of collision problems with the level.
Answer by MK7 · Mar 29, 2011 at 09:33 PM
Figured it out: I used Vector3.forward & Vector3.back to achieve what I was looking for.
Your answer
Follow this Question
Related Questions
How to stop rotation in x and y axis??? 2 Answers
Rotation eulerangles not adjusting correctly... 2 Answers
controller 2 Answers
Rotate object like a safe dial 0 Answers
Unity Mouse Look Script Issue 0 Answers