0 votes

In my project I started without taking in consideration delta so it runs equally in evey PC. Once I realized my mistake I had already made the movement how I liked it so I created a variable called NORMALIZE that would multiply delta * 60 fps because that's what I been working with.

   var NORMALIZE = delta * 60.0

In my head this would normalize the movement to the way I liked it. I then multiplied to my accelerations:

acceleration.x = ((walk + friction + wall_jump_x + external_force_x) * margin_error) * NORMALIZE + offset
acceleration.y = (gravity + jump + wall_jump_y + external_force_y) * NORMALIZE

These are all my forces in the y axis and x axis. What happens tho is: if I put less fps, lets 20fps, my NORMALIZE will go to 3 (instead of 1) as expected but my character jumps a lot higher, even though, I thoought it would decreased. What am I doing wrong?

in Engine by (12 points)

What function does the posted code live in?

1 Answer

0 votes

Acceleration works over time and doesn't return to zero after a frame. So you're setting the acceleration of a jump (that lasts multiple frames) from the delta from a single frame. So if you happen to jump at 20 fps you jump 3 times as high, and if you jump at 120 fps you jump half as high.

_physics_process() runs at constant rate always and is probably what you should use. No normalizing needed.

by (23 points)
edited by

What I thought about normalizing is thinking about if in someone's computer it can't run at 60fps? What would happen then?

Have a look at the documentation for _physics_process(). It is tied to the physics simulation instead of the frame rate (fps) that _process() is. So fps doesn't matter when you're in _physics_process().

Yeah Ive read that. I understand that it'll run alsays at a set fps. But what if the PC can not run the 60fps because lf performance. Let's say it can only run the game at 40 fps. Won't the script be forced to run only at 40fps.

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to webmaster@godotengine.org with your username.