Problem with movement stuttering

Welcome to our brand new Clickteam Community Hub! We hope you will enjoy using the new features, which we will be further expanding in the coming months.

A few features including Passport are unavailable initially whilst we monitor stability of the new platform, we hope to bring these online very soon. Small issues will crop up following the import from our old system, including some message formatting, translation accuracy and other things.

Thank you for your patience whilst we've worked on this and we look forward to more exciting community developments soon!

Clickteam.
  • Hello forum! In my game, I have a problem with my custom movement engine. When moving around, my character moves 2 pixels at a time. This is too fast, but if I reduce it to 1 pixel, it is too slow. 1 is after all half of 2, which means the speed gets reduced by 50%. So I use timeX, and add a small "every" to the movement conditions, so that my character moves by 2 pixels every 5 milliseconds. It isn't a big difference, but it helps. The problem is, using this condition, my character starts stuttering/lagging around every 2 seconds. I tried using the built-in "every" condition, but it doesn't support milliseconds. It only supports centiseconds (100th of a second).

    Can anyone explain to me why this is happening, or explain an alternative to using timeX? I need to move my character slower than 2 pixels at a time, but faster than 1 :P

  • Use fastloop movement. Then you can move in smaller increments smoothly.

    I made an example of fastloop movement a while back. You can find it here: Please login to see this link.

    Please login to see this link.

    My examples:
    Please login to see this link.
    Please login to see this link.
    Please login to see this link.

  • Thanks. That is one way to do it, and it works nicely! There is one thing though; I've heard that fastloops can consume some memory, compared to other things. Will a fastloop movement consume conciderably more memory than a regular movement, or is it too small to notice? Movement for your main character is one of the most important things in the game, so I'd imagine if it does consume a noticeable amount of memory, that it still is important enough to keep, if it works :P

  • Using fastloop for character movement isn't going to slow anything down at all. Fastloops only become an issue when you're iterating through tons of objects or doing too much in each loop. Simply moving a character with the x and y values isn't going to even be noticable. You'll just get the nice smooth movement you're looking for. :)

    Please login to see this link.

    My examples:
    Please login to see this link.
    Please login to see this link.
    Please login to see this link.

  • Allright, thanks a lot :) I will be using that movement instead of the last one I used, because this one saved me from 3 active objects, is easier overall to work with, has less events and also it looks more professional ;) You will be credited!
    I do on the other hand still kind of encounter the problem with the movement speed. If I set the movespeed value to 3, my character moves too fast. If I set it to 2, it moves too slow :P Is there a way to work around this?

    Edited once, last by Yikes (July 25, 2012 at 9:14 PM).

  • You'll have to adjust the frame rate... Basically what's happening is that the fast loop runs through the entire loop each game frame. So the faster your frame rate, the faster your loop finishes... Meaning you might be able to set my example to 60fps and get the result you want... or maybe 55fps.

    Please login to see this link.

    My examples:
    Please login to see this link.
    Please login to see this link.
    Please login to see this link.

  • You can use alterable variables to control the movement as they are able to contain floats whereas the standard x and y positions cant. So:

    start of frame (or whatever)
    ->set xspeed (alt. a) to 1.5
    ->set yspeed (alt. b) to 1.5

    always
    --> set x position to x position + xspeed
    --> set y position to y position + yspeed

    Please login to see this link. | Please login to see this link. | Please login to see this link. | Please login to see this link.

  • Thanks, I reduced the framerate from 60 to 50. Allthough I noticed a small difference in smoothness, it wasn't a problem. The movespeed works now :)
    As for SolarB, I tried that solution earlier, but unfortunately it didn't work. Allthough you use variables that have floats, MMF will still round them up/down to the closest number when using coordinates. You can't move 1.5 pixels, even though that is the number stored in a value :) At least that's what I figured out when I tried :P

  • You need to store the actual positions in alterable values, not just the velocities.

    eg.

    + Always
    -> Set XPos to XPos + XVel
    -> Set YPos to YPos + YVel
    -> Set X position to XPos
    -> Set Y position to YPos

    Fastloops are totally unnecessary here - the screen is only redrawn after the loop has completed, so there's no difference in smoothness between moving 2 pixels once, or moving 1 pixel twice.

    I believe 60fps should give the smoothest results, as most monitors have a 60Hz refresh rate.

  • You need to store the actual positions in alterable values, not just the velocities.

    eg.

    + Always
    -> Set XPos to XPos + XVel
    -> Set YPos to YPos + YVel
    -> Set X position to XPos
    -> Set Y position to YPos

    Nope, can't get it to work. If anyone cares to make an example to prove that it works, please feel free! Otherwise I will be going with a different solution :)

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!