This site is currently in read-only mode during migration to a new platform.
You cannot post questions, answers or comments, as they would be lost during the migration otherwise.
0 votes

Title explains most of it. I'm trying to move the enemy to the player. For some reason, the enemy seems to start moving towards the player (floating) and then when the player starts moving, the enemy starts going up and away from the player? I have no idea what could be going wrong, as everything I've searched through so far seems to be roughly the same and should therefore work?


func _physics_process(delta):
    if areaExported2:
        var velocity = (areaExported2.global_position - global_position).normalized()
        move_and_collide(velocity * SPEED * delta)

func _on_EnemyDetectionRange_area_entered(area):
    if not area.is_in_group("player"):
    if area.is_in_group("player"):
        areaExported2 = area

func _on_EnemyDetectionRange_area_exited(area):
    if not area.is_in_group("player"):
    if area.is_in_group("player"):
        areaExported2 = null

Thank you for any responses, I'm completely stumped as to what it could be.

in Engine by (28 points)

1 Answer

0 votes
Best answer

I've found the problem! My GUI (which I've been working on and off of) used to use an instanced scene of the player in the GUI scene, however, I hadn't removed the player code, meaning that there was an invisible player running around the scene that was screwing with the path finding algorithm. After removing the player from the GUI scene, I'm just working on the GUI now, which I'll probably do with global variables!

by (28 points)
Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.