Forum rules - please read before posting.

Setting a parameter via script?

I have several hotspots triggering one Interaction, and I need an Action in that list to know which hotspot triggered it. So far I intend to solve that by using a gameObject parameter and then setting that value by checking the active Hotspot at runtime and setting the ActionParameter value on it before the interaction occurs.

I can't seem to find out how to do this, though. I thought I could do something like:


but the parameters list is empty. How do I set a parameter value via script at runtime?


  • Im pretty sure you need to add a variable in game editor->Variables->global variables,

    Then from code you can do something like:

    //set real cash from inventory
    GameObject pe = GameObject.Find("PersistentEngine");
    RuntimeInventory rti = pe.GetComponent<RuntimeInventory>();
    List<InvItem> items = rti.localItems;
    for (int i = 0; i < items.Count; i++) // Loop through List with for
    Debug.Log(i+"/ "+items[i].label);
    if (items[i].label.Equals("Money"))
    //Debug.Log("Money found, player has: "+items[i].count);
  • You shouldn't need variables, but your line of code should work.  Know that the active Hotspot is set to null once the interaction begins - perhaps that's the cause.  And I take it doing it the normal way (i.e. without coding) was working?

    @radiantboy: Just so you know, it's much easier now to get AC's scripts:


    will return the RuntimeInventory component.
  • oh nice :-)
  • Thanks Chris, yeah I did find out that the hotspot gets consumed, so what I ended up doing was just check for the last active hotspot in an Update loop and set my value then. It's not as robust as it could be, but seems to work well enough.
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.