Search Unity

[SOLVED] How to trigger Local Volume when custom GameObject enters it?

Discussion in 'High Definition Render Pipeline' started by AlphaDreams, Jul 17, 2020.

  1. AlphaDreams

    AlphaDreams

    Joined:
    Jan 21, 2015
    Posts:
    30
    Hello everyone!

    On our current project, we want to use local volumes in order to dynamically change the "visual mood" of the game if the player enter some specifics zones in our world. If I understand correctly, the change in the post-processing stack is triggered when the camera enters the collider linked to the local volume.

    My question is: Is it possible to trigger a local volume not when the camera enter it, but when a custom gameobject (for example, the player) enter it?

    It can be very useful for us, because the distance and the position between the camera and the player's gameobject is not constant.

    We use the HDRP v7.3.1 (on Unity 2019.3.13f1), Post-Processing Stack v2.3.0.

    Thank you!
     
    lacas8282 likes this.
  2. dgoyette

    dgoyette

    Joined:
    Jul 1, 2016
    Posts:
    4,196
    First, it doesn't really make sense to me that you claim to be using Post-Processing Stack v2.3.0 with HDRP. HDRP has its own post processing, very similar to PPv2, but I don't think they're compatible. Are you sure you're actually using PPv2, and not the post processing built into HDRP, which looks very similar to PPv2?

    As for your question, I don't know of any way to get a local volume to affect a camera if the camera isn't within the bounds of the local volume. For what you're describing (having the post processing effects trigger based on player position when in 3rd-person view), I'd probably just use a global volume and adjust the Weight of it as the player enters or leaves an area. It should be pretty easy to write a script that sets the Weight of a Volume based on whether one object is within a certain distance of another.
     
    AlphaDreams likes this.
  3. AlphaDreams

    AlphaDreams

    Joined:
    Jan 21, 2015
    Posts:
    30
    Oh, I didn't know that there is a built-in HDRP post-processing stack! So, yeah, it's completely possible that we use this instead of the stack installed with the package manager.

    Oh, yeah, that seems quite simple and clever! I'll try to check this, and if everything's work (and if I got time) I will post my implementation here, if it can help someone :)
     
  4. AlphaDreams

    AlphaDreams

    Joined:
    Jan 21, 2015
    Posts:
    30
    Well, finally the solution was much more simple! It's basically just a matter of referencing the player directly in the Camera component, in the field "Volume Anchor Override" :

     
    jajajuaz, W3ktor, CyberSherif and 7 others like this.