Hi Everyone,
I am trying to call a method of a custom script I wrote on a certain item interaction. For this, I have set up the item interaction triggering an action list. There, I use the Object Send Message to call my method. However, I need to pass in a paramater (a string in this case) which the ActionListEditor does not let me do by default. There is an option for passing in an integer but this is not what I need.
I am somewhat stuck on this problem and would greatly appreciate any input.
It looks like you're new here. If you want to get involved, click one of these buttons!
Comments
Welcome to the community, @ACV.
Typically you can get around this either through use of a custom event, or e.g. the "Set Interaction Parameters" component.
Is this within the Hotspot Inspector, or the Inventory Manager? If you can share a screenshot showing the exact place you're workring with, that'll help clarify the situation.
Thank you, Chris!
So I am working with two components here: My own custom c# script "CreatureDrawingManager", which houses the method I want to call.
https://imgur.com/a/z0uFeRy
And the place I am trying to call it (and pass in the parameter from) is this custom interaction between an inventory item and a hotspot in my scene.
https://imgur.com/NswocXH
Maybe there is a better way to do this but basically I have certain hotspots/objects which contain Tags that I need to pass along to my custom script in order to load certain scriptable object datasets and as a trigger, I would like to use custom interactions with one specific item.
This is one of my first attempts to add custom functionality to the AC system so I might be missing something
Apologies btw for the linked pictures, I couldn't get the embedding to work for some reason.
Thanks for the details.
Object: Send message only allows the passing of an integer, but the Object: Call event Action should let you pass a single-parameter value depending on the method involved.
Just be sure to assign the object with the component - rather than the script asset itself - and select the ActivateCreatureDrawing method from the dropdown.
Otherwise, it's always possible to write a custom Action to invoke the method in exactly the way you intend, but from what you describe it hopefully shouldn't come to that.
Also re: Object Call Event - am I subscribing my method to a custom event by using this action? Because in my own code, I have not set up any events yet so so I am wondering how that works.
In any case, thank you for helping out, your tool is a lifesaver!
It's the simplest, but you have a few options for this scenario. "Send message" and "Call event" Actions let you run custom code from an ActionList, custom Actions let you do so with more control, and custom events let you subscribe to common AC tasks.
Which you go with is really a case-by-case choice, though. The Manual's "Integrating new code" chapter covers these options in more detail.
The event is in the Unity sense, and built-in to the Action. With AC events, you can subscribe either through code, or through the Events Editor.
Thank you, Chris!