Forum rules - please read before posting.

Trigger an event through actionlist

edited February 2020 in Technical Q&A

Hi,

I'm trying to trigger the event OnChangeHotspot through an actionlist, but I obviously don't have something setup properly.

I have an actionlist to check when a certain inventory item is selected. When it is selected I want the event OnHotspotSelected to run as I have another script that listens for when this is called to highlight an object. I'm trying to do this through a custom action. In my custom action script I'm trying to run EventManager.Call_OnChangeHotspot(hotspot, true);

hotspot is a public variable I defined earlier so I can drag in any hotspot to the component and "true" is just telling OnChangeHotspot to run OnHotspotSelect. However, I get an error saying "An object reference is required for the non-static field, method, or property 'EventManager.Call_OnChangeHotspot(Hotspot, bool)' "

I'm not sure what I'm doing wrong here. I don't think OnChangeHotspot requires a listener since it's just telling OnHotspotSelected to run, but I feel like I'm overlooking something pretty obvious. Any help would be appreciated. Thanks!

Comments

  • The error is describing the problem: you're calling a non-static method as though it were static.

    See the front page of the Scripting Guide. All non-static component functions can be accessed via their associated KickStarter static variable.

    Try this instead:

    AC.KickStarter.eventManager.Call_OnChangeHotspot (hotspot, true);
    
  • Thank you, Chris! That works.

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.