Quite a long time ago I wrote ready to use scene for touch screen analog sticks. I don’t have instructions on how to use them (they got lost on one of the forum migration).
- Generally you need to add it as a child to ‘Control’ node. Width and Height of this control node will define what is the active area of given Analog.
- You also need to fill “Listener Node Path” property to target your node that will listen to the changes. In this node you need to have function:
analog_force_change(Vector2, Analog )
- Generally you will get normalized Vector2 with percentage joystick shift (range from 0-1 for x and y). And second parameter (Analog) will be handy if you will have more than one analog on the screen (you will be able to check which one is firing this function).
There is also param that will allow you to dynamically hide analog stick when it’s not touched by the user.
It was written quite long time ago, I will update and polish it when we will have asset store (or however it will be called)
Plugin/Scene: Dropbox - analog_stick.7z - Simplify your life
Fast dirty sample project: Dropbox - analog_stick_sample.7z - Simplify your life
And here is short and poor footage on how they work:
Hope this will help!
Great! It was just what I was looking for…
Thanks a lot kubecz3k!
jospic | 2016-02-28 12:38
I used your code for the touch controls of my game Procedural Chaos
I give you credits by linking your account from this forum.
If you prefer something different or to remove your code please inform me.
kakoeimon | 2016-06-24 10:06
Hello, no problem with using my code, I’m glad you find it usefull. If you really want to give credits for me you might use my full name (Jakub Grzesik) or my site (www.kivano.net) or both, but basically you don’t need to if you don’t want
kubecz3k | 2016-06-24 11:48
I don’t understand exactly how it works, but with minimal adaptation it does! Thanks dude!
garred | 2016-11-04 23:22
Thanks for sharing. Too bad the links are dead, but I’ll try to go with the explanation you gave.
Danicano | 2017-04-04 06:32
Links are updated now. Don’t know why, but dropbox decided to make old urls not valid anymore.
kubecz3k | 2017-04-04 07:57
You are great!
Thank you very much!!!
Danicano | 2017-04-04 10:01
Hey, you analog pad works like a charm for me! I will put references if I publish something with that!
Thanks a lot for sharing!!!
Danicano | 2017-04-22 09:48
I recently converted this code to Godot V3 and to work with 2D. I’d be happy to send it your way if you like. It worked pretty good once I figured out all the V2 to v3 changes I needed to make. I used it in my game Batty Bat.
http://geraldwashburn.com/batty-bat/ - Check it out. (Windows Version)
gswashburn | 2018-01-30 06:44
I was in dire need of this, so thank you very much kubecz3k for the original code.
I went ahead and converted it to work in Godot V3, cleaned up the code, documented it, and got it setup for the Godot Asset Store, under a MIT license.
I ensured that on the description I put both your name and your website.
The tool is currently pending aproval on the Asset Store, but will hopefully be up by the time you read this.
Search for Virtual Analog (Catagorized as a tool) to download the tool and an example project.
Once more, thanks so much!
AfterMath24 | 2019-05-23 14:17