using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class ZoomAndMove : MonoBehaviour {
    public bool right = false;

    public float tPassed = 0;
    Vector3 targetScale = new Vector3(1,1,1);
    public int speed = 30;
	// Use this for initialization
	void Start () {
        InvokeRepeating("SwitchDirection", 1, 1);
	}
	
	// Update is called once per frame
	void Update () {

        transform.localScale = Vector3.Lerp(transform.localScale, targetScale, 0.01f);

        if (right)
        {
            targetScale = Vector3.one * 1.5f;
            transform.Rotate(Vector3.forward * speed * Time.deltaTime);
            
        }else
        {
            targetScale = Vector3.one * 0.5f;
            transform.Rotate(Vector3.forward * -speed * Time.deltaTime);
        }
        	
	}

    void SwitchDirection()
    {
        right = !right;
    }
}
