- Home /
Make camera rotate don't stop
Guys, I need your help.
I wan't to make the main camera to rotate around the scene. Just rotate, not moving or following something.
The code below worked and I have an exported apk where it works. But somehow when I reopened the Unity it doesn't work anymore.
function Update () {
transform.Rotate(Vector3.down * Time.deltaTime * rotationSpeed);
}
This code only makes the camera rotate for 1 frame. I want it to never stop.
What am I missing here?
Is this script attached to the camera you'd like to spin? What's the value of rotationSpeed
? Are there any other scripts or functions which might be disabling or otherwise interfering with your script? When you go to build, do you see any errors in the Unity Editor's console window?
Rutter, yes, this script is attached to my mainCamera.
To avoid the problem with other scripts, I created a new scene and a new one Script with only that code and attached it to the mainCamera. I get no errors in the console window, but it still don't work, still spin for 1 frame.
About the rotationSpeed, doesn't matter the value I put on it, 2, 20 or 50. It just defines how much the Cam will spin in the only frame where it spins.
I'm trying to figure out what is happening. Can it be a Unity's preference option?
Thanks for your help.
Answer by Mefistofel · Nov 14, 2013 at 05:30 PM
Create object in the center and attach Camera object(on the distance) and the Script on it.
void Update () {
transform.localRotation *= Quaternion.Euler(0, needAngularSpeed * Time.deltaTime, 0);
}