+1 vote

so i have a mob logic, and when it is initially facing the player it follows it just fine and successfully collides. however when the player hops over the mob it still follows it but stops at a safe distance from the player therefore not damaging it.
here's the code:

#player detection logic, ideally if it works
func onArea2Dbodyentered(body):
if player == body:
detected = true func onArea2Dbodyexited(body):
detected = null function for animations and player detection logic func animationsanddetection():
velocity = Vector2.ZERO
if detected:
playerpos = player.globalposition
velocity = position.direction
to(playerpos).normalized() * minSpeed else: animation.play("idle") if velocity.x > 0: get_node("AnimatedSprite").flip_h = true else: get_node("AnimatedSprite").flip_h = false

func physicsprocess(delta):
velocity.y = gravity * delta
velocity = moveandslide(velocity, Vector2(0, -1))

pictures for better understanding of what happens:
the (more or less) intended way on the mob's face:
my problem on the opposite face:

in Engine by (15 points)

Please log in or register to answer this question.

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 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 webmaster@godotengine.org with your username.