Make sure to paste scripts instead of screen shots.
Character bodies should make use of their velocity propertiy with either move_and_collide or move_and_slide. In your case I suppose move_and_collide would be better.
First, do not edit position directly. calculate your movement vector then apply it.
func _physics_process(delta: float) -> void:
var move_vector: Vector2 = position.direction_to(player.position) * speed
var collision = move_and_collide(move_vector * delta)
if collision:
pass # do a bounce?!
Now using velocity you can modify it over time to result in more fluid movement
extends CharacterBody2D
const ACCELERATION = 12 # speed * 4
@export var player: CharacterBody2D
func _physics_process(delta: float) -> void:
var move_vector: Vector2 = position.direction_to(player.position) * speed
velocity = velocity.move_toward(move_vector, ACCELERATION * delta)
var collision := move_and_collide(velocity * delta)
if collision:
velocity *= -1 # negative flip bounce
velocity = velocity.bounce(collision.get_normal()) # normal-based bounce