Page 1 of 1

onUse Touch Button

Posted: Thu Jul 21, 2022 4:49 pm
by Albyd
Hi guys, I'm here to ask for some help.
I would like to link the onUse function to a UI Touch Button.
It will be used as an "Action" button to interact with npcs and objects.
Can you help me?

Many thanks
Albyd

Re: onUse Touch Button

Posted: Thu Jul 21, 2022 9:18 pm
by Tony Li
Hi,

If you're using a Proximity Selector component, you can tick Enable Touch and specify the Touch Area. For example, if I set the Origin and Alignment to Bottom Left, and set the Width and Height to Normalized 0.5 (that is, 0.5 x the screen size):

selectorTouchArea1.png
selectorTouchArea1.png (45.22 KiB) Viewed 233 times

Then the touch area will be here:

selectorTouchArea2.png
selectorTouchArea2.png (170.76 KiB) Viewed 233 times

If you don't want to use the Touch Area or Proximity Selector, there are other solutions. If you're using a Selector or Proximity Selector, you can manually call the Selector or Proximity Selector's UseCurrentSelection() method.

If you're not using a Selector or Proximity Selector, you can manually call the target's OnUse() method, or send "OnUse" to all of its components like this:

Code: Select all

target.SendMessage("OnUse");

Re: onUse Touch Button

Posted: Fri Jul 22, 2022 8:05 am
by Albyd
Thank you very much bud.
I was stuck with this problem and your comment really helped me!

Re: onUse Touch Button

Posted: Fri Jul 22, 2022 8:49 am
by Tony Li
Glad to help!