user3690398
user3690398

Reputation: 25

Unity3D Moving Camera from left to right and vice versa C#

How to make camera move constantly from left to right and vice versa relatively to screenCenter and without inputs, i mean automatically from the start of the game. By 'move' I mean 'watch' like as if you were turning your head to the right and to the left without changing an original position.

Upvotes: 1

Views: 946

Answers (1)

Tzah Mama
Tzah Mama

Reputation: 1567

This is a simple example of turning script (tune it to whatever suits you best)

int timer = 0;
int direction = 1;
// Update is called once per frame
void Update () {
    if (timer % 50 == 0)
        direction *= -1;
    transform.Rotate (new Vector3 (0, 1 * direction, 0));
    timer++;
}


Also, check out Unity Answers they should be of more help

Upvotes: 1

Related Questions