- Home /
GameObject rotation maxing out at 180
I am using the current code to rotate a camera and the rotation stops at 180. I would like it to continuously rotate so how would you fix this code?
var speed : int = 5;
function Update () {
gameObject.transform.rotation.y += speed*Time.deltaTime;
}
You should not address the individual components of transform.rotation. It is a Quaternion...a 4D construct that is not intuitive. Ins$$anonymous$$d you can do:
function Update () {
transform.Rotate(0.0, speed*Time.deltaTime, 0.0);
}
mytransform.Rotate(0,1,0);
if you just wanna rotate around the y here is a simple way I added a var transform and a speed which you would multiply against the 1 in the Y position
all out here it is
var speed : float = 5;
var mytransform : transform;
void Start () {
mytransform = transform;
}
void Update () {
mytransform.Rotate(0,1 * speed * time.deltatime,0);
}
Answer by N13s · Jun 10, 2013 at 11:09 AM
Like bodec mentions in the comment section, every object's rotation properties are actually a Quaternion. look for a video on Youtube about Quaternions, so you understand how they work.
Your answer
Follow this Question
Related Questions
Using the accelerometer to rotate Camera 1 Answer
Troubles instatiating a gameobject with rotation 0 Answers
My marble (Player/Gameobject) goes through the "play board" (gameobject). Why? 1 Answer
How to keep a Gameobject in the same position after a transform.Rotate? 2 Answers
Rotate "ghost object" then instantiate object with that rotation 1 Answer