Using dt results in jerky movement... why?

0 favourites
  • 4 posts
From the Asset Store
With this template you will learn how to use the GooglePlay Games native plugin
  • Hi all! I'm working on a little road-crossing game where Sprite objects (cars) do not only move but also gradually grow bigger as they grow closer to the "camera" (imitating 3D). The way it works is every tick the scale of each car changes depending on their distance from the "camera" (i.e. their position on the Y axis):

    Every tick: car_lane1: Set scale to scale1+car_lane1.Y*0.0006[/code:1jhaq2pt]
    
    This is what it looks like, to give you an idea:
    [img="https://image.ibb.co/naGCba/chicken.png"]
    
    So, this works alright as a framerate-dependent game, but as soon as I try to use dt (by e.g. multiplying the value above by 60*dt) the cars start "shaking": changing their size uncontrollably many times a second (even as they generally grow bigger or smaller, depending on which direction the cars are going). Does anyone have any suggestions regarding why this may be happening and how to fix it?
    
    Thanks!!
  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • xlomid

    I would scale the cars based on their Y positions. Just use dt on car movement.

  • If you are using any behaviours to move or resize the objects... dt already applies automatically to behaviours.

    You may also find that you need to bracket your equation a little there, so it knows where to apply the *dt.

    scale1+(car_lane1.Y*0.0006)*dt - maybe? My implementation/use of dt is a bit sketchy at times too, lol.

    ~Sol

  • Thank you both! Using dt on car movement only did the trick, and scaling is now as smooth as it was before!

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