Godot – create a joystick.

I used Godot version 3.0.6 to create a joystick scene for the game.
First, you need to activate the touch option from Project Settings – Display – Windows – Emulate Touchscreen.
This will allow you to use the touchscreen into your game.
Create a scene with the name Analog and add one CanvasLayer.
Rename the CanvasLayer to Analog and add a Sprite.
Rename the Sprite to Big and add to this a new Sprite and rename it Small.
Add textures to the Big and Small sprites to have a joystick on screen.
Create two scripts for Analog and Big with the same names.
Add this code source to the script Analog.gd:

The source code for Big.gd is this:

To use this joystick just add the scene to your player and import the variables like this:

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.