Explanation why we can't take the input in _physics_process function

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By mendacium

So I was trying to make a simple Kinematic2D object move.

My code : 88Tscg7KiJ | SourceBin

It works, but I have 2 issues.

  1. Why do I need to use 5000 as a multiplying factor with my normalized vector where the example on the Godot page achieves same smooth motion with 500 ?

  2. Why do I need to put the input checking function in the get input function and call it from there ? I had put the code into the physics process function but the kinematic body did not move then. To my knowledge, the physics process function is called at regular intervals so why can’t we check input there ?

Sorry, if these questions are noob-ish, I am a beginner (15min experience in Godot and game dev)

:bust_in_silhouette: Reply From: kidscancode
  1. This probably has to do with your scale. The 500 or 5000 is how much you’re scaling your velocity. If your object is large, 5000 pixels/sec is a good speed. If it’s small, 500 pixels/sec may be all you want.

  2. You are checking input in the _physics_process() function. Placing the input code in its own function and then calling it from _physics_process() is a matter of keeping the code organized. It is easier to troubleshoot and modify this way than if you had just one giant function with all the code in it.