3D Clipping when KinematicBody (move_and_slide_with_snap) is on a vertical moving platform

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

Hello everyone! How are you all doing?

This happens only when the characters is on a vertical moving platform. For horizontal movements everything is fine. I’m using a KinematicBody being moved by a move_and_slide_with_snap function. All the margins are already set to 0.001. The platform is being moved by an AnimationPlayer set to Physics.

Thanks!

A GIF showcasing the issue:

Here’s the player script:

extends KinematicBody

export var gravity = 3000

export var move_speed = 750

#jump
export var fall_multiplier = 1 
export var low_jump_multiplier = 10
export var jump_force = 1300
export var max_fall_speed = 3000

var y_velo = 0

var snap_normal = Vector3.DOWN setget set_snap_normal

func movement(delta):
	var move_vec = Vector3()
	if Input.is_action_pressed("move_left"):
		move_vec.x -= 1
	if Input.is_action_pressed("move_right"):
		move_vec.x += 1
	move_vec = move_vec.normalized()
	move_vec *= move_speed
	move_vec.y = y_velo
	move_and_slide_with_snap(move_vec * delta, snap_normal, Vector3.UP)
	
	var grounded = is_on_floor()
	y_velo -= gravity * delta

	if grounded:
		if Input.is_action_pressed("jump"):
			set_snap_normal(Vector3(0,0,0))
			y_velo = jump_force
		if y_velo <= 0:
			set_snap_normal(Vector3.DOWN)
			y_velo = 0
	if y_velo > 0 and Input.is_action_just_released("jump"):
		y_velo -= 30 * (low_jump_multiplier)
	elif y_velo < 0:
		y_velo -= 7 * (fall_multiplier)

func set_snap_normal(new_snap_normal):
	snap_normal = new_snap_normal

func _physics_process(delta):
	movement(delta)