Implementing Kinematic System


With my last post, I figured it'd be good to clarify how I implement this Godot kinematic system (GKS). The system has a process method that is not one of the standard pre-made methods. It is a process method called in its parent _physics_process method and does the following steps:

  1. Receive input - the kinematic body should have a handle_input() method and if it does, the GKS calls it. 
  2. Apply input & forces - the GKS takes the applied input and applies proper forces, including gravity. If there are maximums we care about (i.e. max walk speed or terminal velocity), we call a method to clamp these values.
  3. Pre-move - I've designed the system to have two methods to let the body do stuff just before and right after the move. The kinematic body should have a pre_move() method where they can put anything they want the body to do before the move. 
  4. Move - the GKS checks the collisions before the move and records them as the previous state. The body's move_and_slide is called and then the checks are done again and recorded as the current state.
  5. Post-move - This is the same as pre-move but for... you know... post-movement.


    Leave a comment

    Log in with itch.io to leave a comment.