Hello, can someone please advise me on how to get a reference to the Trigger that calls an Action? For now I'm dragging the Trigger scene object into the slot, but would like that to be automatic. Thanks!
It looks like you're new here. If you want to get involved, click one of these buttons!
Comments
I'm using the custom action to switch cameras (A to B/B to A) with a single trigger.
https://youtu.be/Uv_ZmNQv4kc
Welcome to the community, @DNG_PHM_David.
For this situation, you'll want to rely on AC's ActionList parameter workflow - which lets you re-run the same ActionList with modified Action values.
Rather than checking which Trigger was run, you can just have a single Camera: Switch Action - and dynamically change which Camera it references each time it runs.
To do this, follow these steps:
When the Player then enters the Trigger, it should then run the ActionList asset - and set the parameter value to the assigned camera, which should in turn then be used in the "Camera: Switch" Action.
A more general tutorial on the use of parameters can be found here. A more complex video tutorial, which covers a few use-cases of this workflow, can be found here.
Hi Chris, thanks for the info. My action isn't checking which trigger is run, it's only using the trigger gameobject's transform data to determine a relative direction to the player. If it's positive, then return true. If negative, return false - which determine which output path to follow. That's why I wanted to reference the trigger that's calling the action because I only need a ref to the gameobject and it will always be the calling trigger for that action. I'm using AC_Trigger as the type instead of GameObject for stronger typing to prevent user error - which I wouldn't need of course if I can pull the ref in the code instead of manually dragging in the reference from the hierarchy.
Also, the action isn't just for cameras. Since I can determine which side of the trigger I'm entering, I can better manage runtime events depending on direction of player travel and not worry about triggering on backtracking and such. I can turn on/off lights, spawn items when I enter or leave a room, etc. with just the one trigger. So setting up the env is much less cluttered.
However, since I'm just getting used to porting my C# code to AC, this was very helpful and I'm going to try it out to learn a bit more about all this.
Understood, thanks for clarifying.
You could still use the same concept, in the sense of defining a "Invoked Trigger" GameObject parameter, and then assigning itself in the "Set Trigger Parameters" component.
However, you also could bypass the Trigger's own Actions in favour of a separate ActionList that is run via the OnRunTrigger custom event. Since this event passes the invoked Trigger as a parameter, you can pass it onto an ActionList as a parameter that way:
Either way, once you have the Trigger as a GameObject parameter within the ActionList, you can then either rely on it using a custom Action, inject it as an override for GameObject fields, or check its value with the ActionList: Check parameter Action.
Interesting. Yeah this is why I came to the forum - so I could understand the AC ecosystem like this. Thanks for the insights!