Camera jumping to final position despite regulating speed.
So I've just begin coding in Unity and am having an issue with getting my camera to scroll across a text box. The lower bound for my camera (x-axis) is -6.16 (set by me in the scene) and the upper bound is 12.56. Here is the attached code I am using to animate the camera :
void Start ()
{
Debug.Log ("Animation started.");
}
public int enter = 1;//Just to ensure that the loop isn't entered once again after the main camera reached 12.56
void Update ()
{
//Lower bound : -6.16 (x)
//Upper bound : 12.56
if (enter == 1)
{
while (this.transform.position.x<12.56)
{
this.transform.Translate (0.02f, 0, 0,Space.Self);
Debug.Log (this.transform.position.x);
}
enter++;
}
}
}
When I hit play, the Main Camera 'jumps' from -6.16 to 12.56 on the game window and just stops there. On the other hand the Debug.Log command shows me all values between -6.16 and 12.56 and the positions where I would except my camera to be.
Looking forward to your suggestions.
Thanks
Your answer
Follow this Question
Related Questions
Moving an object smoothly over predetermined distance without defining begin and end points 0 Answers
How can I apply a position (and not a translation) to my camera related to an axis value 0 Answers
[Solved] Linear movement speed, reset position 1 Answer
Moving walls in multiple places 1 Answer
How can I move an object between two positions, while it is on a rotating platform? 0 Answers