All Questions

Community

Grominet
posted to: Project setup

Why don't we use the delta variable ?

Why don't we use the delta variable in the Player's _physics_process function ? I thought the variable was meant to make the game more fluid in case some physic frames were lagging.

move_and_slide(direction * movement_speed * delta)
  • GDQuestions replied

    Move and slide takes a velocity (speed * direction) as its input parameter and applies the time delta internally. That's why you don't pre-multiply the velocity by delta, unlike with move_and_collide.

    Note this is something we typically explain in our beginner tutorials but as this is advanced-level we don't repeat it. Also to learn more, you can Ctrl+Click the method name: the code reference explains how it works in details.

  • Grominet replied

    You're totally right, I should have ctrl click the method name, sorry. Thanks for your answer!

  • GDQuestions replied

    Don't apologize, I'm here to help!