- Home /
Rotate Camera Slowly
Im having a circular game board containing 40 tiles . i have to rotate camera onto every third tile . well performed functionality . but when it moves it gives a jerk cos of waitforseconds used to delay movement. well i used Slerp and used Time. delta Time but it didn't give any suitable result . can anyone suggest how to perform it ?
show your sources first. fixing mistakes takes a lot less time then writing a scripts from scratch
You probably don't want WaitForSeconds() you probably just need to yield return null;
But as @Scroodge$$anonymous$$ says, please post the relevant bit of code.
for(Tile =1;Tile<=60;Tile++) { lGoTargetTile = GameObject.Find( "tile"+Tile+"target"); Floatdistance = Vector3.Distance(lGoTargetTile.transform.position,lobj$$anonymous$$ainCamera.transform.position); if(Floatdistance>.3 && Tile%3==0) { lobj$$anonymous$$ainCamera.transform.rotation = Quaternion.Slerp (lobj$$anonymous$$ainCamera.transform.rotation,lGoTargetTile.transform.rotation,Time.deltaTime); } }
Answer by Ranger-Ori · Jul 24, 2012 at 06:33 AM
First, when you post a script, you should post it in the "Answers", and not in the "Comments" section, since it's a bit hard to read.
I think you should multiply the Time.deltaTime with a variable, and in case you want the rotation even slower, you should set the variable as a decimal number. 0.1/0.5..., 0.01/0.25.., 0.001... and so on until you'll get the suitable rotation.
thanx for d format . i have tried the fixed values also . it ddnt work .
Answer by Humb · Jul 24, 2012 at 07:36 AM
for(Tile =1;Tile<=60;Tile++)
{
lGoTargetTile = GameObject.Find( "tile"+Tile+"target");
Floatdistance = Vector3.Distance(lGoTargetTile.transform.position,lobjMainCamera.transform.position);
if(Floatdistance>.3 && Tile%3==0)
{
lobjMainCamera.transform.rotation = Quaternion.Slerp(lobjMainCamera.transform.rotation,lGoTargetTile.transform.rotation,Time.deltaTime);
}
}
Ahh I get it, the problem is because the computer "Find" all tiles at one framerate speed, and rotates it in the very moment. a for loop executes in the Update function in 1 frame. What you should do, is do these commands outside the for loop. Then add it a factor for speed.
im using this code in start function . and yes may be that can be the reason . how could i overcome that or is it same in start too as update .
Start function only starts once. Awake function starts every time the script is called. Update/LateUpdate/FixedUpdate are functions that are renderered all the time. (in different framerates speed) you should use FixedUpdate, it's better for physics and movement.
actually im new to unity and dont know much . so ill hav to check . thanx for d reply
Your answer
![](https://koobas.hobune.stream/wayback/20220613074444im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Rotate a cube using touch 0 Answers
Rotating camera, but it slows down after ~30 degrees? 0 Answers
rotating a bone slows down frame rate considerably 1 Answer
Android screen rotation very slow and my audio keeps going but the graphics stop 0 Answers
Flip over an object (smooth transition) 3 Answers