Search Unity

Events don't trigger with AR camera

Discussion in 'Scripting' started by bh02vz, May 11, 2019.

  1. bh02vz

    bh02vz

    Joined:
    Feb 7, 2019
    Posts:
    6
    Hello.

    I am trying to get my AR camera to trigger an event to change the Post Processing behavior attached to it. I followed this tutorial "Unity Tutorial - How to Create Underwater FX". In it the person uses a normal camera and i assumed treating my AR one as he does his camera would work. It didn't.

    I have attached a colider to both my camera and my object which is a box of water and would like the screen to change using PostProcessing Stack from the asset store. The code in the video is as such:
    Code (CSharp):
    1. using System.Collections;
    2. using System.Collections.Generic;
    3. using UnityEngine;
    4. using UnityEngine.PostProcessing;
    5. public class ChangePostProcess : MonoBehaviour
    6. {
    7.    
    8.     public PostProcessingProfile normal, fx;
    9.     private PostProcessingBehaviour camImageFx;
    10.    
    11.     void Start()
    12.     {
    13.         camImageFx = FindObjectOfType<PostProcessingBehaviour>();
    14.     }
    15.  
    16.     void OnTriggerEnter(Collider col)
    17.     {
    18.         if (col.CompareTag("Player"))
    19.         {
    20.             camImageFx.profile = fx;
    21.         }
    22.     }
    23.  
    24.     void OnTriggerExit(Collider col)
    25.     {
    26.         if (col.CompareTag("Player"))
    27.         {
    28.             camImageFx.profile = normal;
    29.         }
    30.     }
    31. }
    And yet the event doesn't seem to trigger.