-
Manual Mode.
- Create
plugins
folder in project root. - Download this repo and put all files inside a
touchJoyPad
folder (inside aplugins
folder). - Use
touchJoyPad.tscn
scene in your project.
- Create
-
Git Mode.
- if you not started git repo before, start it
git init
- in first time
git submodule add https://github.com/shinneider/godot_touchJoyPad.git ./plugins/touchJoyPad
- in next repo clone, clone normally, after clone, run
git submodule update --init --recursive
- if you not started git repo before, start it
-
Basic configuration.
- Arguments.
After import scene check Inspector tab of Godot
- Left Pad Style:
Select
tipe of Joy
, a classicalD-Pad
or a modernAnalog
. - Map Analog to DPad:
Analog send analogic signal(between -1 and 1), but if set this, the
signal is converted
to nativesui_left
,ui_up
,ui_right
andui_down
signal (if you need, is possible to receive analog singal too). - Visible Only Touchscreen:
Visible
only
indevices with touch
capabilities. - Analog Tap To Show:
This
show the analog
just ifuser tap in the screen
.
- Left Pad Style:
Select
- Arguments.
-
Receive Analog movimentation.
- The touchJoyPad is attached to the group Joystick see this
- On each Analog movimentation ths function
analog_signal_change
is fired. The funcanalog_signal_change
analog_signal_changeanalogPosition
andanalogName
. - The
analogPosition
argument
is x,yAnalog coordinates
(x and y containsvalues between -1 and 1
) being thatx < 0
is moving to theleft
,x > 0
moving toright
,y < 0
movingdown
,y > 0
moving toup
, and finallyx = 0 and y = 0
isn't moving
. - The
analogName
argument
is way tofilter Analog signal
if you decide tore-use
the Analog scene (Ex: two analog in screen
, left for movimentation and right for aim). - Ex:
analog_signal_change
implementation.func analog_signal_change(analogPosition, analogName): # When to move Analog, send signal to natives ui signal # but implements a dead zone in 20% in the curso of Analog # This is good for to avoid user mistakes in move hand Input.action_press("ui_left") if analogPosition.x < -0.2 else Input.action_release("ui_left") Input.action_press("ui_right") if analogPosition.x > 0.2 else Input.action_release("ui_right") Input.action_press("ui_down") if analogPosition.y < -0.2 else Input.action_release("ui_down") Input.action_press("ui_up") if analogPosition.y > 0.2 else Input.action_release("ui_up")
-
Analog Tap To Show.
- If you
need to use this
, you need toput de scene inside
aViewportContainer
or aerror occurs
andnot compile
. - This
occurs because
theViewportContainer
isused to determine a area
ofTap To Show
. - Ex:
two Analog
,one in each corner
of the screen, theViewportContainer
determines area of each Analog
, without this all screen active the two analogs
- If you
-
Obs in standalone use of
DPad
orAnalog
.- If you need to
use manually
the plugins,you need to implement logic
for this cases:Hide
(Becauseenable = false
,mantains the touch area
,i sugest
move button for out of the screenposition = Vector2(-1000, -1000)
).Hide if touch device
(Check if touch device usingOS.has_touchscreen_ui_hint()
).Pass the param AnalogTapToShowContainer
(Used for the Analog in Tap To Show)for default he search ViewportContainer in up parent
, but if you need, just specify a parent for her (Ex:$"leftPad/JoyStickLeft".AnalogTapToShowContainer = get_parent()
).
- If you need to
-
Help in Test/Debug.
- to help in your test in desktop without touchscreen, enable godot touch emulator.
- Go to
Project Settings
, on the left menu searchPointing
insideInput Devices
. - Enable
Emulate Touch From Mouse
, on this enable, mouse is used as touch on the screen.
Using Analog with tap to show:
- kubecz3k First version of code analog.
- gswashburn Port code analog to Godot 3.
- kenney.kl Art for analog and D-Pad.