Delta Time Issue

Hello,

I am new around here, I started working with Defold a few days ago and impressed with my experience so far. I have decided to work through the tutorial to get a better feel for the elements involved with putting a game together.

Everything was well until the end of section 5 when I came to test my parallax scrolling background and my character running animation.

Firstly I was to set the background scrolling speed to 6, then setting my characters jump take off speed to 900 and a gravity value of -20. The background scrolls that fast it is a blur and my character won’t leave the ground when jumping unless I increase the jump speed to some value greater than 5000.

I thought I would try the plat-former game which was provided, that too also ran extremely quick, which got me looking into the delta time of the update function. I noticed in Defold Editor 2 the Dt variable is not set by default for this project and after ticking it, it resolved my issues with the plat-former demo.

After rushing back to my project I was only disappointed to find out that was not the issue I was experiencing there.

If anyone should shed some light on the issue or let me know what information they require to assist me that would be great.

Thanks.

1 Like

There’s a known issue with the engine on Windows (only?) where certain gfx drivers misbehave and run faster than specified. I believe we started looking into this a while back (@Johan_Beck-Noren?) but I can’t remember what we came up with.

But just to be clear: You’re moving things in update() and you use the dt to adjust the distance you move things?

Apologies for the delayed response. I am actually using Linux but I believe the issue was with the tutorial itself. It does not actually implement dt within any update function of the ground script.

Ah, yes, you’re right, the tutorial doesn’t make use of delta time. @sicher, surely that’s something we could improve on?

So, the solution would be to increase self.speed and then do:

pos.x = pos.x - self.speed * dt
1 Like