Forum rules - please read before posting.
Tech questions during the weekend? Drop in on the community Discord channel!

How to trigger a C# script in an action list.

Hello, 

So currently I want to open a door that swings open via animations. I have a script that will do this, however I want to trigger it in an action list. 

SO for example, I want the player to click on a hotspot, it triggers a few dialogues, then calls a c# script. 

Here is something that visualises of what I want to do 

https://i.imgur.com/mtWOH0t.png

Previously Chris mentioned I can use "send message" or call event. I cant seem to figure out how to do it, or see anything in the manual to see. 

Some additional information: 

The door opens and closes using a script being triggered on mouseDown via a box collider. However I want to rejig this so I can trigger the event inside the action list using AC hotspots. 

Thanks for your help!

Comments

  • You can't just "trigger" a script as a whole - you need to specify a function within that script to run.  Your proposed Action has fields for the script and the GameObject it's placed within, but not the function within that script.

    Calling a script function can be done with both the Object: Send message and Object: Call event Actions, as you've said.

    Object: Send message works by choosing the GameObject with the script in question, and then the entering the name of the function you want to trigger as the "message".  A selection of built-in function names are provided ("TurnOn", "Kill", etc), but you can enter your own via the Custom option.

    Object: Call event works by choosing the GameObject with the script in question, and then locating the script component, and public function within that script, via the drop-down selector beneath it.

    Note that in both of these cases, the function called must have no parameters.  If the script function you want to run has them, you'll need to write a new function inside the script to trigger the "real" function with the parameters correctly set, and then call the new one via the Actions instead.
  • Thanks Chris, you're a legend as always, object Send message worked a treat
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.
Do NOT follow this link or you will be banned from the site!