Trigger a function

I’m working on a WebGL project and want an NPC to send a signal that activates a highlight/selection function in a separate script (not directly triggering an action).

What I’m Trying:

  • The NPC should communicate with another GameObject’s script to highlight it.
  • I need this to work without tight coupling between the NPC and target script.

Questions:

  1. What’s the best way for the NPC to “signal” another script?
  2. Are there specific Unity functions or systems (like events, messaging, etc.) I should try?
  3. Any code examples or best practices for this type of communication?

Hello @SoftIli_Dev,

Welcome to the Convai Developer Forum!

Unfortunately, I’m not entirely sure I understand your exact use case. If you’re referring to triggering an event based on the NPC’s interaction, please note that the Action system is not supported in the WebGL SDK.

You mentioned that the NPC should send a signal—could you clarify the conditions under which this signal should be sent?

Feel free to provide more details about your requirements.:blush:

Hi, thank you for your response!

I understand that the Action system is not supported in WebGL. Currently, I’ve set it up so that when a user selects an object (for example, a cube) using my selection and highlight code, it sends a message to the NPC, such as “Tell me about this cube.”

What I’d like to achieve is the ability to ask the NPC, via voice command, to select the cube. The NPC would then send a message that is interpreted by the same voice recognition system, which would call the selection function in my code. Is this what the Action system is for?

To clarify, I don’t need the avatar to perform any animations or movements—just the selection functionality. Is there a way to achieve this selection via voice command now, or should we wait for an update to the Action system?

Thank you!

Hey @SoftIli_Dev,

Great news!

With the 2.1.0 update, Action support is now available in WebGL. :tada:

Please try it out and see if it meets your requirements:
Convai Unity WebGL SDK - 2.1.0 Release

Let us know if you need any assistance! :blush:

1 Like

Just in time, great work

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.