using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Rendering;
using UnityEngine.Rendering.Universal;


public class VignetteController : MonoBehaviour
{
    private Rigidbody player;
    public Volume vignette;
    public float threshold = 5f;
    public float maxValue = 1f;

    void Start()
    {
        player = GameObject.FindGameObjectWithTag("Player").GetComponent<Rigidbody>();
    }

    // Update is called once per frame
    void Update()
    {
        if(vignette.profile.TryGet(out Vignette vig)) //https://www.youtube.com/watch?v=8S22Qt_-nY8
        {
            float value = (Mathf.Abs(player.velocity.x) + Mathf.Abs(player.velocity.y) + Mathf.Abs(player.velocity.z)) / threshold;
            if (value > maxValue) value = maxValue;

            vig.intensity.Override(value);
        }
        
    }
}