Forum rules - please read before posting.

Finding the hotspot from which an interaction has been called

edited January 2023 in Technical Q&A

Dear Chris and everyone else,
I'd like to write a Custom Action which somehow gets the hotspot it has been called from, to launch a script attached to the hotspot itself.
For instance, mouse interact with Use on Hotspot, Hotspot runs an "Use" interaction, the custom action inside the interaction action-list recognize the hotspot gameobject that called it, and therefore finds the script within it to execute (as hotspot.gameObject.GetComponent< MyOtherScript >().launchMyStuff();)

Is there a way to get that via script/CustomAction?

Thanks a lot

Comments

  • If a Hotspot's Interaction ActionList has a GameObject parameter, the Hotspot Inspector will let you map that parameter to the Hotspot.

    A tutorial on incorporating parameters into custom Actions can be found here.

  • edited January 2023

    Ok, I'm investigating it...

  • So, I've tried following that tutorial, but it seems that I need to link the Game Object to the interaction, and if so, then I could have done also an Object - Call Event. But what I need is to use the same single interaction for all the hotspots that relies on that interaction, each of them with different "MyScript" parameters. So I was wondering if there was some sort of event or other kind of catcher, that returns the "hotspot" object that triggered the interaction containing my custom action.
    Following the tutorial you linked, apparently setting the Hotspot parameter: GameObject doesn't call the Game Object within the hotspot, but the Game Object linked in the interaction, which is not what I need.
    Or maybe I'm understanding wrongly what you are suggesting...

  • When the "Hotspot parameter" field is set, the GameObject parameter its set to will be set to the GameObject of the Hotspot - not the Interaction.

    You can trigger a public function on that GameObject by using the Object: Send message Action, and using that parameter to override its Object to affect field.

  • Thanks! With Object: Send message it works!
    So I wondered what was wrong with my custom action (which I copied from the tutorial above), and the issue was in the assignvalue of "objectToAffect" (I simply forgot to paste the very last part of the tutorial code). Now also my custom action works! All good! Rookie mistake.

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Welcome to the official forum for Adventure Creator.