Help needed - Weird physic behaviour when pushing a 2D object

Godot Version

Godot 4.7 rc3 mono

Question

Good afternoon. I’m currently working on a push mechanic that I want to integrate in my game.

I’ve managed to implement it and it is working as expected.

I’m facing a weird thing though. When I start to push the object, it offsets itself by a few pixel forward before moving. I do not know what could causes such a weird behaviour.

Can you help me please ?

P.S:

I’ve shared the code of the player and the pushable as well as a video that demonstrates the problem.

Code :

class_name Player extends CharacterBody2D


const SPEED: float = 300.0
const JUMP_VELOCITY: float = -260.0

var manipulated_vel: Vector2

var _is_pushing: bool
var _push_direction: float
var _pushable: Pushable

@onready var push_raycast: RayCast2D = %PushRaycast


func _physics_process(delta: float) -> void:
	# Add the gravity.
	if not is_on_floor():
		velocity.y += get_gravity().y * delta
		_clear_pushable()


	# Handle jump.
	if Input.is_action_just_pressed(&"jump") and is_on_floor():
		velocity.y = JUMP_VELOCITY

	var direction: float = Input.get_axis(&"left", &"right")
	push_raycast.target_position.x = 20.0 * signf(direction)

	if not _is_pushing:
		if direction:
			velocity.x = direction * SPEED
		else:
			velocity.x = move_toward(velocity.x, 0, SPEED)

		if _detect_pushable():
			_is_pushing = true
			_push_direction = signf(direction)
			_pushable = push_raycast.get_collider() as Pushable
			_pushable.is_pushed = true
	else:
		velocity.x = _push_direction * SPEED
		if is_on_wall() && _pushable:
			_pushable.velocity.x += 128.0 * _push_direction

		if signf(direction) != _push_direction:
			_clear_pushable()
			_is_pushing = false

	move_and_slide()


func _detect_pushable() -> bool:
	return push_raycast.is_colliding() && push_raycast.get_collider().is_in_group(&"pushable")


func _clear_pushable() -> void:
	if _pushable:
		_pushable.is_pushed = false
		_pushable = null


Pushable :

class_name Pushable extends CharacterBody2D

@export var max_push_speed: float = 128.0

var is_pushed: bool


func _ready() -> void:
	add_to_group(&"pushable")


func _physics_process(delta: float) -> void:
	if !is_on_floor() or !is_pushed:
		velocity.x *= 0.0
	elif is_on_floor() && is_pushed:
		velocity.x = clampf(velocity.x, -max_push_speed, max_push_speed)

	if !is_on_floor():
		velocity.y += get_gravity().y * delta

	move_and_slide()

Images :