Shifting the Analog Stick to Where the Player Touched

Hey everyone, thanks to previous help here, as well as the excellent VirtualGamepad example and the associated britzl/defold-input library, I have managed to implement a virtual gamepad for my game.

I am currently trying to improve the controls of my game a little bit - i am thinking about moving the centre of my virtual analog stick to where the player touches, as opposed to where having it in a static location.

i am not sure what the best way to do this is - intuitively i guess i am supposed to shift the centre of the analog stick node to where the user has touched - is that really all there is to it? or is there something else that i need to take care of? or perhaps there is a simpler way to do it?

This seems like something that would need to be done quite often, so if anyone has seen an example somewhere that would be a great reference for me as well. thanks!

That seems about right. You will have to call onscreen.register_analog() again after you’ve repositioned the analog stick.

1 Like