Using dt results in jerky movement... why?

Get help using Construct 2

Post » Mon Aug 07, 2017 5:36 pm

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):

Code: Select all
Every tick: car_lane1: Set scale to scale1+car_lane1.Y*0.0006


This is what it looks like, to give you an idea:
Image

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!!
B
3
Posts: 4
Reputation: 183

Post » Mon Aug 07, 2017 9:34 pm

@xlomid

I would scale the cars based on their Y positions. Just use dt on car movement.
Image
B
30
S
9
G
3
Posts: 171
Reputation: 3,329

Post » Mon Aug 07, 2017 11:50 pm

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
Tired of crappy file hosts that are crappy? Get DROPBOX - https://db.tt/uwjysXJF
Moderator
B
83
S
34
G
40
Posts: 3,032
Reputation: 30,474

Post » Wed Aug 09, 2017 3:22 pm

Thank you both! Using dt on car movement only did the trick, and scaling is now as smooth as it was before!
B
3
Posts: 4
Reputation: 183


Return to How do I....?

Who is online

Users browsing this forum: David181, manujorgo, NECRONOMICRON and 27 guests