How is it that the amount of pixels a player moves is constant when multiplying it by delta time?
I know that when you don't use delta time, the players speed will be affected by how many FPS your pc runs the game. Meaning if i can run the game at 60fps, my player would move many more pixels than if my PC were running the game at 30fps. But how is that delta time fixes this and makes it so the players always move the same amount of pixels regardless of my frame rate?
I know that the delta time calculates the time it takes to process one frame to the next. But how does this make it so the pixels is constant? Depending on my machine, it may take more time to go frame one frame to the next. So how does it make the pixel rate constant? I'm so confused
Posted Feb 8, 2021, 4:54 AM UTC
You have to decide on the pixels per second your objects move Thats the speed you multiply by delta -> 0.16 for 60fps So each frame your obj moves 0.16 of the distance it will move in a second
That way if your frame takes longer, yiur obj will skip frames to the real time position instead of slowing down
Likewise if you draw in less than .16sec your obj will draw more times to move the exact same distance
I think I get it.
So basically, if I want to move my player 15px with every frame, that would mean the player would move 900px per second at 60FPS. However if my machine was not as fast and it ran the game at 30FPS, it will still achieve a 900px per second movement by skipping frames? Meaning it would draw the player less times on the screen so it can still move the same distance?
Yepperz you got it
Thank you!