Trying to move a Rigidbody2D as a kinematicbody2D

I am probably not going to be the last one that asks about this. I need a character like a kinematicbody2D, but one that responds to 2D physics.

As such, I am having a very hard time grasping how to move horizontally without physics, and vertically with physics simultaneously.

This was my attempt with just left and right movements, but the character kept sliding around like it was on ice (which isn’t in this first level at least, lol. Maybe it will be necessary later).

func _physics_process(delta):

if Input.is_action_pressed("left") and not Input.is_action_pressed("right") and damaged == false:
motion.x  = -SPEED
elif Input.is_action_pressed("right") and not Input.is_action_pressed("left") and damaged == false:
motion.x  = SPEED
else:
motion.x = 0

func _integrate_forces(state):
if motion.x != 0:

My next attempt was to use linear velocity for movement and just stop all of the movement on the X axis, but this has proven to be impossible with the physics-based jumping mechanics. That code is very long and doesn’t really show what I am trying to do, so I’ll just add the jump if statement here from that code:

if Input.is_action_pressed("up") and on_ground == true and timeut == false:
motion.y = -JUMP_SPEED
apply_central_impulse(motion)

PS: physics would be necessary more later in the game, where the character swims, walks on surfaces of various frictions, accidentally ends up on a conveyor belt… All kinds of crazy stuff, but I won’t spoil it.

If you want to stop x motion it can’t be done by applying a force of zero. It will remain in motion.

To gradually reduce motion you need to apply damping/friction.

You should set the state.linear_volicity.x to 0, to freeze motion or multiply the velocity.x with a value between 0.0 and 1.0, exclusive, to slow movement.

Okay… but how do I start movement? It always seems like the start of a drag race- you start with the vehicle/player hardly moving, and then they go full-throttle, faster than I want in the platformer.