Hi. I'm making first-person mobile game with virtual joystick which i asked before.
The hotspot setting that I want is like Granny mobile game.
(video :
https://youtu.be/yiFklZVAUCM)
When the locked center cursor with proper raycast distance to the item, 'Hand button'
appears on GUI.
I have no idea after set to
Settings manager - Hotspot detection method : Player Vicinity.
(added sphere collider as a child with Ignore Raycast layer)
Or, is it appropriate method by
Settings manager - Interface settings - Interaction method : Custom Script,
and then write a custom interaction script?
I would appreciate your advice!
Comments
If you check Lock cursor in screen's centre when game begins? (in the Setting Manager), then Hotspots will only be detected when in the centre of the screen. You can stop distant Hotspots from being detected by reducing the Hotspot ray length value further down.
To have the hand icon appear, you just need to create a new Menu that displays it, and have its Appear type set to On Hotspot. Have the icon displayed as a Button element, and then set the Button's Click type set to Simulate Input. Enter the Input axis as InteractionA (which doubles for a single-click on the Hotspot itself), and it should then trigger the interaction when tapped.
Finally, to prevent tapping on the Hotspot / scene itself, create an "invisible" Menu that spans the screen area. Just be sure to keep it at the top of the Menu stack, so that others are displayed/interacted with on top of it.
I'm sorry but I can't find Lock cursor in screen's centre when game begins? setting in Touch Screen input method.
If I set On Start Game ActionList - Player: Constrain - Cursor lock: Enable, Nothing happens when I tap the screen. All of touch don't work. (T_T)
It may be that a custom script is necessary after all - I'll look into it.
Input method: Touch Screen
Interaction method: Context Sensitive
Hotspot detection method: Custom Script
Then paste the following into a C# script named "AutoSelectCentreHotspot.cs", and attach it to a new GameObject in your scene:
http://pasteall.org/938123/csharp
Then create a new Menu to display your hand icon. Set it's Appear type to On Hotspot, and make the hand icon with an Interaction element inside it.
The script should select the centre-Hotspot for you regardless of the touch / cursor position, and the Menu should then turn on allowing you to press the Interaction icon to use the Hotspot.
I also changed Interaction method: Custom Script and add some codes for my use button.
----------------
---------------------------
And I also added 'on click' function to hand button(Unity UI, not AC menu), which sends message "UseInteraction".
I do not know if I've edited the code in the right way(I'm in a beginner level), but it works as i want!
Thank you so much and I feel like I learned more through this time.
Sorry, could I have this code again?
"Then paste the following into a C# script named "AutoSelectCentreHotspot.cs", and attach it to a new GameObject in your scene:
http://pasteall.org/938123/csharp"
The link is missed now.
Thank you
I don't have the original code, but it was along these lines: