How to activate proximity selector with touch

Announcements, support questions, and discussion for the Dialogue System.
Post Reply
User avatar
rauljl1
Posts: 55
Joined: Fri Apr 15, 2022 7:40 pm

How to activate proximity selector with touch

Post by rauljl1 »

As the title said, i want to activate the proximity selector by touching (android) an actor, for example an NPC instead of useKey or useButton. By the way, I see the Enable touch check, but I can't understand how it works.
Thank you very much for your help!
Last edited by rauljl1 on Fri Apr 15, 2022 8:16 pm, edited 1 time in total.
User avatar
Tony Li
Posts: 22149
Joined: Thu Jul 18, 2013 1:27 pm

Re: How to activate proximity selector with touch

Post by Tony Li »

Hi,

There are two ways to activate a Proximity Selector with touch: using the Enable Touch checkbox, or showing a UI button that the player can touch. Neither requires any scripting.

Enable Touch
If you tick Enable Touch, you can set the Touch Area. You can specify an origin (e.g., top left corner of the screen) and an alignment (e.g., align the top left corner of the touch area to the origin). Then set the X & Y offset and the Width & Height. You can specify the X, Y, Width, and Height in absolute pixels or a normalized value 0...1. For example, if you set the Width to normalized with a value of 1, the area will be the entire width of the screen.

When the player touches this area, it will send "OnUse" to the selected Usable.


Show UI Button
Alternatively, you can add a UI Button to the Proximity Selector's canvas (e.g., a copy of the Basic Standard UI Selector Elements instantiated by the Dialogue Manager's Instantiate Prefabs component). Configure the OnSelectedUsable() UnityEvent to activate this button. Configure OnDeselectedUsable() to deactivate it. Configure the button's OnClick() Unity Event to call the ProximitySelector's UseCurrentSelection() method.


BTW, if you don't like either of these options, you can always configure your own interaction system to send "OnUse" to usable objects.
User avatar
rauljl1
Posts: 55
Joined: Fri Apr 15, 2022 7:40 pm

Re: How to activate proximity selector with touch

Post by rauljl1 »

Thanks Tony, I solved it by calling the UseCurrentSelection method on a button press on a small canvas wich contains my npc :D .
User avatar
Tony Li
Posts: 22149
Joined: Thu Jul 18, 2013 1:27 pm

Re: How to activate proximity selector with touch

Post by Tony Li »

Sounds good! Happy to help.
Post Reply