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

public class TreeSway : MonoBehaviour {

    public float speed = 3;
    public float amount = 10;
    float zAngle = 0;
    float ogAngle = 0;
    float offset;

    // Start is called before the first frame update
    void Start() {
        ogAngle = transform.eulerAngles.z;
        zAngle = ogAngle;
        offset += Random.Range(-0.2f, 0.2f);
    }

    // Update is called once per frame
    void Update() {

        zAngle = ogAngle + Mathf.Sin((Time.time+offset) * speed) * amount;

        transform.rotation = Quaternion.Euler(
            transform.eulerAngles.x,
            transform.eulerAngles.y,
            zAngle
        );
    }
}
