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
onUse Touch Button
Re: onUse Touch Button
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):
Then the touch area will be here:
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:
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):
Then the touch area will be here:
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
Thank you very much bud.
I was stuck with this problem and your comment really helped me!
I was stuck with this problem and your comment really helped me!