Jerky character movement, and I don't know why [SOLVED]

0 favourites
  • 4 posts
From the Asset Store
Piano Tiles with Sound Keys - I don't have 50 words to type here
  • The basic info

    Here is a GIF of the movement. What is happening here is the player character (orange ball) is falling from a high area, and moving at about 1200 px per second (different speeds are the same), and the red text is an FPS counter. I move left and right a bit to show that it's happening.

    http://i.imgur.com/NpPUrST.gifv

    All the other details

    A few days ago I notice that I am getting jerky movement while moving around the main character in my game, and after a few hours of messing around with no results, I started a new project based on the platformer template, and was getting the same issue. The odd thing is that this only appears to be happening on my work PC, and not the one at home.

    Things I have tried:

    • Running the game in different browers, as well as nw.js
    • Updating Construct 2 and nw.js to latest beta
    • Updating my video driver
    • Compiling the project to see if perhaps it'll run better that way (nope!)
    • Blood offerings to Cthulhu
    • Putting an FPS counter (as seen in the GIF) to see if the jerky movement coincides with FPS dips (it doesn't)

    Since I'm planning on releasing a demo for my game in the coming months I would like to get this taken care of asap so hopefully nobody else has this issue, or at the very least figure out what's causing it so I can put a disclaimer out.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • It is usually impossible to determine what the problem may be just from looking at a gif.

    What would help is the full spec of the PC in question and a simple .capx that shows the issue.

    It is more than likely that the issue is with the PC but more information is certainly needed.

  • My friend figured it out as soon as he saw the GIF! Crazy.

    Ok, so I had to apply the delta time function to the camera I made, as it wasn't frame rate independent like the player that it follows (the Player object uses the platform behavior which already has Delta Time applied to it). Before setting up the camera, I noticed that every once in a while the game might hitch for a fraction of a second, but when I added the camera without the DT function, the ball would just jerk when the game would hitch (very technical, eh?).

    Anyway, for anyone adding a camera to follow a player that's using either the platform or 8 direction behavior (I believe it's different for the Physics behavior), here is how you set it up so that it is framerate independent:

    • Create a blank sprite near your player (preferably on the same layer, though this isn't necessary as long as there is no special layer properties such as parallax), this will be your camera, From here on we'll assume the player object is named "Player", and the camera sprite is named "Camera"
    • Give the Camera the "Scroll To" behavior.
    • Remove the "Scroll To" behavior from the Player object if it has one.
    • Do the following in the corresponding event sheet: Add Event > System > Every Tick. Then click"Add Action" > choose the camera sprite > "Set Position".
    • For X enter: lerp(Self.X, Player.X, 1 - 0.012 ^ dt)
    • For Y enter: lerp(Self.Y, Player.Y, 1 - 0.012 ^ dt)

    The "0.012" number you can adjust between 0 and 1 for different camera following speeds. I have a very fast player object, so I have the camera follow very quickly, but you can tweak the number as you see fit. If you need more information on lerp or any other aspects of this, there are numerous camera tutorials out there, but all of the ones I came upon skipped the part for Delta Time, and they looked like this:

    X = lerp(Self.X, Player.X, 0.012)

    Y = lerp(Self.Y, Player.Y, 0.012)

    Hopefully this makes sense to some people or helps one of you down the road!

  • Vpick

    Thank you very much!

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)