Sprite gets stuck / starts glitching at certain location

Hi! New to GDevelop and looking for some help with a bug in my game.

After two clicks, I am sending a sprite to a specific (x,y) location on a screen. I do this with both a left button and a right button. The general workflow is when a click on a button is released, it’s add to a ‘clicks’ variable for that button. When the ‘clicks’ variable hits 2, the sprite is sent off to the provided location and when it arrives the ‘clicks’ variable is set back to 0. The code is exactly the same for the left and right button versions of this (can see the code below).

The left version works great - on the second click it goes exactly where I want it to a resets. But the right version glitches and I can’t figure out why. After the second click it heads towards the location but when it gets to the x position of about 1120 (supposed to reach 1176) it starts vibrating in place and doesn’t move past that location without me hitting the right button again and manually moving it over to x=1176 (at which point the ‘clicks’ variable resets properly). I cannot for the life of me figure out why that would be and any help would be hugely appreciated.

I’ve added the code for moving towards the location. I can’t show the rest because new users can only add one image apparently but I can send over more if that’s helpful. The only part really missing is just that when the click is released on the right/left buttons +1 is added to the ‘clicks’ variable for that button (and the general move logic associated with the buttons).

TIA!

There are 2 conditions that can be met simultaneously - events 2 and 4 in the screen shot. The arm can be at an x position that both greater then 768 and less than 1176. I suspect these could be the cause of the issue.

If all you’re doing is moving the arm left or right, you might want to consider using a positional tween They’re easy to set up, you don’t need to do anything else once you’ve set it up and it’d get rid of this problem.

Correct they can be met simultaneously, but they apply to different variables so I didn’t think it’d be an issue? And why would that cause it to flicker in one place (~x=1120) while letting me move it further right in that case?

Could you elaborate on the positional tween?

Thanks so much for the response and help!

Not sure, though it wouldn’t surprise me if it’s something in the other events.


A solution with a tween for the left movement would look like:

Do it similarly for the right movement, naming the tween “MoveRight”.

And here’s a link to the different type of easings.