How can I solve this jerky motion of my sprites?

PupolajshuPupolajshu Posts: 4Member
edited January 1 in 2D

Basically, I was making my Space Inviders game when I decided to try going fullscreen. In the
project settings > General > Display I set
use_vsync true ,
stretch_mode 2d,
fullscreen on,
stretch_aspect keep.
The sprites I move are under Kinematic body2d
But when I launch the game in editor or when exported, the horizontal motion is jerky... it twitches and stuff...
I put my exported project and godot project in dropbox so you can check it out yourself if you need.
My question goes like this - Why is it happening and how can I get rid of this problem?
Have a nice day ;)

Link to exported file (.exe):
https://www.dropbox.com/s/guzqtfloy2vh1g1/mgame.exe?dl=0

Link to project(rar):
https://www.dropbox.com/s/7in64skc2jxxbqi/SpaceInviders.rar?dl=0

Answers

  • BinaryOrangeBinaryOrange Posts: 101Big Boss

    What operating system are you using?

    Unfortunately, Godot seems to have some sort of glitch with 2D physics on Windows, where sometimes the motion of a sprite is rendered very jerkily. However, this doesn't seem to happen on Linux or Mac OS. I believe the bug is either being ironed out now, or will be ironed out in Godot 3.0.

    I have discovered that multiplying my movement values by delta seems to alleviate the problem quite a bit, I suggest giving that a shot and seeing if it offers any improvement for you as well.

  • PupolajshuPupolajshu Posts: 4Member

    @BinaryOrange said:
    What operating system are you using?

    Unfortunately, Godot seems to have some sort of glitch with 2D physics on Windows, where sometimes the motion of a sprite is rendered very jerkily. However, this doesn't seem to happen on Linux or Mac OS. I believe the bug is either being ironed out now, or will be ironed out in Godot 3.0.

    I have discovered that multiplying my movement values by delta seems to alleviate the problem quite a bit, I suggest giving that a shot and seeing if it offers any improvement for you as well.

    Thank you for your answer.
    I am using Windows 10.
    I also asked this question in chat and others who tried running my game said that the movement is jerky for them too.
    And I also tried multiplying the movement value by delta. It didn't solve the problem unfortunately.
    This is very weird because moving the ship(also Kinematic body) the same way moves it smoothly....

  • AvencherusAvencherus Posts: 34Member
    edited January 4 Answer ✓

    Generally you want to use move() and move_to() for KinematicBody.

    move(Vector2(-speed*delta,0))

    Also if you want smoother movement, you would want to use acceleration and velocity to control it. Applying desired friction to slow it as well, and possibly having a maximum speed clamp if your desired values spiral it out of control.

    However, looking at your example, I'm thinking most of your problem here is actually just the contrast. When you have pure white against dark or black backgrounds you're going to fatigue your eye's receptor cells. It's the basis for many optical illusions where you see motion in things that aren't moving. The cells in your eye get exhausted, send bad data, recover, and repeat that process, and you end up seeing strange things.

    Take a look at this and see if you feel something familiar. X)

  • RossRoss Posts: 180Member

    Yeah, I think it's just a visual thing too. I've been messing around with this, trying different things. Even if you just turn the 'filter' flag on on your invader sprite, it looks a lot less jittery. I tried changing the sprite. If I set it to a circle, a fuzzy dot, or anything with a varied contour, and it looked perfectly smooth, but if I set it to a flat square, it looked jittery. Actually, just rotating the sharp square or your space invader sprite a bit made it look a lot smoother, though some angles still looked bad.

    . . . this is all after I tried changing the code, the methods, the node type, etc. None of that did anything.

  • PupolajshuPupolajshu Posts: 4Member

    @Avencherus said:
    Generally you want to use move() and move_to() for KinematicBody.

    move(Vector2(-speed*delta,0))

    Also if you want smoother movement, you would want to use acceleration and velocity to control it. Applying desired friction to slow it as well, and possibly having a maximum speed clamp if your desired values spiral it out of control.

    However, looking at your example, I'm thinking most of your problem here is actually just the contrast. When you have pure white against dark or black backgrounds you're going to fatigue your eye's receptor cells. It's the basis for many optical illusions where you see motion in things that aren't moving. The cells in your eye get exhausted, send bad data, recover, and repeat that process, and you end up seeing strange things.

    Take a look at this and see if you feel something familiar. X)

    Yes, this might be it...
    I am currently working on one game for Game Jam and my sprites are not jittery :smile:

Sign In or Register to comment.