How to make moving RigidBody2D's push a KinematicBody2D, and not the other way around?

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

The scenario I’m trying to change is that, when a KinematicBody2D player character is on top of a square RigidBody2D (in Rigid mode) that has an impulse applied to it, the KinematicBody2D blocks upward movement and makes the box spin if the impulse is horizontal.
A clip of the current behavior: https://gfycat.com/vigilanttintedjanenschia

How can I make the RigidBody2D keep its momentum and push the KinematicBody2D?

Could you post some of your code? Especially the part that makes the player move.

SweetPie | 2022-10-20 23:52

The movement is mostly copied from the KinematicBody2D demo project.

	
	func _physics_process(_delta):
		(other stuff)
		var direction = get_direction()
	
		var is_jump_interrupted = Input.is_action_just_released("jump") and _velocity.y 	< 0.0
		_velocity = calculate_move_velocity(_velocity, direction, speed, is_jump_interrupted)
	
		var snap_vector = Vector2.ZERO
		if direction.y == 0.0:
			snap_vector = Vector2.DOWN * FLOOR_DETECT_DISTANCE
		# var is_on_platform = Area2DBottom.get_overlapping_bodies()
		_velocity = move_and_slide_with_snap(
			_velocity, snap_vector, FLOOR_NORMAL, false, 4, 0.9, false
		)
		(other stuff)
	
	func get_direction():
		jumping = false
		if jump_buffer_frames_left > 0:
			if is_on_floor() or coyote_frames_left > 0:
				jump_buffer_frames_left = 0
				jumping = true
			else:	
				jump_buffer_frames_left -= 1
		elif Input.is_action_just_pressed("jump"):
			if is_on_floor() or coyote_frames_left > 0:
				jumping = true
			else:
				jump_buffer_frames_left = jump_buffer
		return Vector2(
			Input.get_action_strength("move_right") - 	Input.get_action_strength("move_left"),
		0.6 * jump_force if jumping and not Input.is_action_pressed("jump") else jump_force if jumping else 0
		)
	
	func calculate_move_velocity(
			linear_velocity,
			direction,
			speed,
			is_jump_interrupted
		):
		var velocity = linear_velocity
		velocity.x = speed.x * direction.x
		if direction.y != 0.0:
			velocity.y = speed.y * direction.y
			
		if is_jump_interrupted:
			# Decrease the Y velocity by multiplying it, but don't set it to 0
			# as to not be too abrupt.
			velocity.y *= 0.6
		return velocity```
[wrap=footnote]die_dai | 2022-10-21 05:13[/wrap]