HI,i have some problem in postProcessing effects

hi, I have completed my tower defence game, I want to add a cutscene in-game at the start of my game scene in which I want to modify the value of depth of field in a cutscene but I don’t know how to do it using script or timeline

here’s my code that didn’t work


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

public class CurScene : MonoBehaviour
{

    [SerializeField] DepthOfField depthOfField;
    [SerializeField] LensDistortion lensDistortion;
    [SerializeField] float depthOfFieldClearValue = 25;
    bool done = false;
    // Start is called before the first frame update

    private void Awake()
    {
        depthOfField = FindObjectOfType<DepthOfField>();
        lensDistortion = FindObjectOfType<LensDistortion>();
    }

    void Start()
    {
        StartCoroutine(controlEffects());        
    }


    IEnumerator controlEffects()
    {

        while (!done)
        {
            Debug.Log("start");
            if (depthOfField.focusDistance.value < depthOfFieldClearValue)
            {
                depthOfField.focusDistance.value ++;

            }
            
            lensDistortion.intensity.value++;
            if(lensDistortion.intensity.value > 0)
            {
                done = true;
            }
            yield return new WaitForSeconds(.1f);
        }
    }
}

this code is supposed to increase focus distance and intensity but it doesn’t change any value in the post-processing effect

Hi,

Have you already tried to add Debug.Logs to your code to see what is going on during runtime? And have you tried to test parts of your code with the camera to see if you access the correct properties and get the desired results?

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.

Privacy & Terms