Hello, i'm trying to activate a postprocess effect only when "use" interaction is used in a hotspot, i've already looked inside the scripting guide in search of something like "use interaction is used" or something similar, but i have serious problems to find what i'm looking for, i know its just my lack on scripting. Any help would be appreciate. Many thanks
It looks like you're new here. If you want to get involved, click one of these buttons!
Comments
You can incorporate whatever change you need into the Hotspot's Interaction ActionList - either by using a custom Action, or with the Object: Call event / Object: Send message Actions to trigger a function in a custom script.
It's also possible to hook into the OnHotspotInteract custom event, which gets fired when a Hotspot interaction is run. The following script, DetectHotspotInteraction.cs, will detect when the Hotspot it's attached to is interacted with:
Perfect Chris, i've used the script because i'm missing still some knowledge on Object: Call event / Object: Send message. Ive finished the script would you mind to give it a look? Just to tell me if i'm right with the inverse of
if (hotspot == GetComponent ())
https://pastebin.com/VQyAa8Gd
Is that way working with every interactions present in a hotspot or its usable only in a single interaction?
The event will trigger for all interactions, though you can read the properties of the Button parameter if you want to filter them.
If this effect is intended for all Hotspots - not just specific ones - only one instance of the script is necessary, with no need for a GetComponent check.
Is that last code block intended to run once the interaction's over? The hotspot parameter will never be null, but you can hook into the OnEnterGameState event to check if the game has re-entered Normal gameplay (assuming the Interaction itself blocks gameplay when running):
All right, clear. That must work, thanks again, Chris.
Ok i'm back on this, i did some try but it didn't work, effect activate when hotspot is on but doesn't turn off, even without giving me some errors or alerts. As i can't still fly by myself, i'm thinking for something maybe more easy to learn based on my scripting skills. Is possible to detect a menu open/close instead of "OnHotspotInteraction"? Probably will help me more.
Well, i'm starting to understand, EventManager is life saver. One last thing on this topic, i did this script, would you mind to give it a check just to tell me if theres something useless or i can avoid to use? Heres the final script ( don't worry about DoF values changing even if effect is off, i just need those as a reminder) XD
using UnityEngine;
using AC;
using UnityEngine.Rendering.PostProcessing;
public class DetectExamineMenuOpen : MonoBehaviour
{
}
Looks good to me!
Only thing I'd suggest is that maybe you can lose the "effectActive" variable, since the m_dof.active is always set to the same value.
Thank you Chris.