Horizontal movement not multiplied by delta?

I’m curious about why we didn’t multiply the horizontal movement by delta. I noticed when I tested this in mine it slowed the character way down, but doesn’t leaving off delta mean that horizontal speed is determined by the speed of your computer, that it’s no longer frame rate independent? Or is there another reason behind it, something that Godot handles in the background that I’m just missing? Thanks in advance for clarifying.

1 Like

Morning Thomas, good to see you back on the forum :wave:

You’re right in your thinking there with something in background :wink:

I did have the same question on the Udemy QnA, so I’ve popped my slightly rambly explanation below.

Hope it helps, if there’s any bits that I’ve not covered please shout.

in the physics process, move_and_slide() already takes delta into consideration and is applied for us behind the scenes.

theres two things going on here, that were wanting a different behaviour for and we have to look at what their measured in.

Velocity - this is a force in Metres per Second thats applied to the character body. and as we are using move_and_slide(), its already multiplying this Velocity by Delta for us to get this fraction of a second movement value.

this is where the difference comes in, Gravity is an accelleration, so its in Meters per second squared.

so velocity is Meters * Second
Gravity is Meters * second * second

as godot doesnt differentiate what gravity is, its just taking the gravity value and multiplying by delta a single time with the move_and_slide()

but, we want to multiply by seconds again to change this to accelleration, so were multiplying it once by delta ourselves, to get the m/s and then move and slide with further use delta itself to multiply and give us the M/S^2 value.

it could be used without this delta multiplication for gravity, but would need to turn the gravity value down to like 4-5 ish, it would just have a jump thats linear, still looks ok, just not with the nice ease-in-out look to it that comes in the template as default.

hope that sort of helps, think i kind of rambled there a bit :slight_smile:

3 Likes

Thanks so much for your detailed response! This really helps me understand the overall physics context, which will help me make good decisions in the future as well as this moment.

1 Like

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.

Privacy & Terms