Search Unity

Updating Post Processing Volume in Real Time (2019.3)

Discussion in '2D' started by bendelany693, Jun 10, 2020.

  1. bendelany693

    bendelany693

    Joined:
    May 10, 2020
    Posts:
    3
    Hi everyone, I'm trying to set up a script so that as my player's health gets lower, the chromatic aberration effect increases. Right now, I have a Volume set up so that its effects can be seen in the scene and game views, but I can't access it through a script. Declaring a public PostProcessVolume won't take my Volume as an argument, but when I switch from a Volume to a Post-Process Volume its effects can't be seen in the scene or game views.

    This is my PostProcessing setup:




    This is my script I've been working with:
    Code (CSharp):
    1. using System.Collections;
    2. using System.Collections.Generic;
    3. using UnityEngine;
    4. using UnityEngine.Rendering.PostProcessing;
    5.  
    6. public class aberrationController : MonoBehaviour
    7. {
    8.     public PostProcessVolume volume;
    9.     // Start is called before the first frame update
    10.     void Start()
    11.     {
    12.         ChromaticAberration ca;
    13.         volume.profile.TryGetSettings(out ca);
    14.         ca.intensity = new FloatParameter { value = 1 };
    15.  
    16.     }
    17.  
    18.     // Update is called once per frame
    19.     void Update()
    20.     {
    21.         ChromaticAberration ca;
    22.         volume.profile.TryGetSettings(out ca);
    23.         ca.intensity.value = 1f;
    24.  
    25.     }
    26. }
    27.