Sending the user through Usable.

Announcements, support questions, and discussion for the Dialogue System.
Post Reply
User avatar
Oafkad
Posts: 2
Joined: Tue Sep 17, 2024 10:35 pm

Sending the user through Usable.

Post by Oafkad »

Maybe a weird question. I'm just getting into this system and I was noticing the Usable class. I figured I might consolidate my own interaction system and just use this.

The downside to this idea is that it looks like the use functions cannot pass data through them? Is there a clean way to tell and object who interacted with them?

If the game only had players interacting that wouldn't be too big of a deal, but the critters in my game interact with items and one another.

Just trying my best to not have two different interaction systems in the game. So if this exist in some fashion that'll be handy. Perhaps I'm looking at the problem wrong, not sure.
User avatar
Tony Li
Posts: 22104
Joined: Thu Jul 18, 2013 1:27 pm

Re: Sending the user through Usable.

Post by Tony Li »

Hi,

The Usable component is primarily just used for targeting. It tells the Selector or Proximity Selector that the GameObject is targetable, although it does have those utility UnityEvents which are often used to activate and deactivate some kind of visual indicator on the Usable GameObject.

When a Selector or Proximity Selector uses a Usable, it also invokes OnUse(Transform user) to all scripts on the Usable GameObject, and optionally to all of the Usable GameObject's children if Broadcast To Children is ticked.

So you only need to add a method of your own that has an OnUse(Transform user) method.
User avatar
Oafkad
Posts: 2
Joined: Tue Sep 17, 2024 10:35 pm

Re: Sending the user through Usable.

Post by Oafkad »

Tony Li wrote: Wed Sep 18, 2024 7:54 am Hi,

The Usable component is primarily just used for targeting. It tells the Selector or Proximity Selector that the GameObject is targetable, although it does have those utility UnityEvents which are often used to activate and deactivate some kind of visual indicator on the Usable GameObject.

When a Selector or Proximity Selector uses a Usable, it also invokes OnUse(Transform user) to all scripts on the Usable GameObject, and optionally to all of the Usable GameObject's children if Broadcast To Children is ticked.

So you only need to add a method of your own that has an OnUse(Transform user) method.
Ah sweet, secondary broadcast should do precisely what I need. Thanks!
User avatar
Tony Li
Posts: 22104
Joined: Thu Jul 18, 2013 1:27 pm

Re: Sending the user through Usable.

Post by Tony Li »

Glad to help!
Post Reply