• Godot HelpProgramming
  • Can someone help with my touchscreen movement script please? - move_and_slide() has jittery movement

So I've been working on a 2D Android game, and something weird is happening with my movement. All the Vector numbers seem fine. They aren't jumping around or anything, but for some reason it still looks a little jittery when my player is moving, especially when I run it on my Samsung Galaxy S7.

I scripted a touchscreen analog joystick, and I was thinking maybe because I'm setting the player position based on the stick position relative to the touch position, there might be something going on there I'm not seeing. I know movement with physics bodies should be scripted in physics_process(delta), but does it matter that the stick position is found in input(event)? Isn't input handled before physics processes?

A zipped folder of project can be found here --> https://www.dropbox.com/s/qa2pgf3sc3ipwgi/Move_Test%20-%20Copy.zip?dl=0

If someone wiser is the ways of Gdscript could point me in the right direction as to what I'm doing wrong, I would be eternally grateful!!

@myNameIsPaul said: So I've been working on a 2D Android game, and something weird is happening with my movement. All the Vector numbers seem fine. They aren't jumping around or anything, but for some reason it still looks a little jittery when my player is moving, especially when I run it on my Samsung Galaxy S7.

I downloaded the project, and everything looks fine for me. I did not test on Android as I do not have an Android device, but at least on Windows 10, using emulate touchscreen in the Godot project settings, everything seemed to be working fine.

... I know movement with physics bodies should be scripted in physics_process(delta), but does it matter that the stick position is found in input(event)? Isn't input handled before physics processes?

I do not think it matters that movement is in _physics_process and the analog stick uses _input. I made a analog joystick (for a tutorial ) using _input and it works fine and has no jittery movement, including on iOS with two analog joysticks at the same time. (Or if it does have jittery movement, I did not see any)

Looking at the code, I'm wondering if the jitter is coming from the Tween node. Maybe try commenting out the code using the Tween node, and/or using lerp instead and see if that helps?

Another thing you could try that may potentially increase performance is adding tween.stop() before you call tween.interpolate_property. It could be that the Tween node is making a new tween process every time you call tween.start() but it's not getting rid of the previously created tween processes.

I am just guessing though. I didn't see any jitter on my PC, so it's hard to pin point what could be causing the issue.

Thanks for the reply @TwistedTwigleg

Commenting out the Tween code didn't seem to make a difference. Although adding the tween.stop() did make it a little smoother on my computer. Didn't change the jitteriness on my Android however. I will try it with lerp next when I get some time.

I tried running your test project for your tutorial and it seemed to run a lot smoother on both my computer and my Android, so maybe I will try and re-write mine based on yours. Also, the second page of your tutorial doesn't load, just says the page can't be found.

Thanks again for your help, I really appreciate it! I will update once I get your analog stick working on my project.

Commenting out the Tween code didn't seem to make a difference. Although adding the tween.stop() did make it a little smoother on my computer. Didn't change the jitteriness on my Android however. I will try it with lerp next when I get some time.

Strange. Hopefully lerp will help!

I tried running your test project for your tutorial and it seemed to run a lot smoother on both my computer and my Android, so maybe I will try and re-write mine based on yours. Also, the second page of your tutorial doesn't load, just says the page can't be found.

Whoops! Thanks for letting me know! It's all fixed now!

Thanks again for your help, I really appreciate it! I will update once I get your analog stick working on my project.

No problem! Hopefully the analog joystick will help. Thanks again for letting me know about the tutorial page not loading!

4 years later