Godot Version
4.2.2
extends CharacterBody2D
var gravity = ProjectSettings.get_setting("physics/2d/default_gravity")
var chase = false
var spd = 100
func _physics_process(delta):
# Add the gravity.
if not is_on_floor():
velocity.y += gravity * delta
var player = $"../../player/player"
var direction = (player.position - self.position).normalized()
if chase == true:
velocity.x = direction.x * spd
move_and_slide()
func _on_detector_body_entered(body):
if body.name == "player":
chase = true# Replace with function body.
Question
my mob should follow the player when he gets close enough,
but when the mob notices the player it just goes left and only left, what’s wrong?