DragonAero64

Godot Enemy doesn't face player

Jul 11th, 2024 (edited)
9
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
GDScript 0.49 KB | Source Code | 0 0
  1. func _on_detect_box_body_entered(body): # Used when enemy DetectBox is entered
  2.     collisionX = body.position.x # Get player's position on collide
  3.     if body is Player: # Make sure it's the player
  4.         if collisionX > position.x: # This if statement is likely my source of error.
  5.             directionX = 1
  6.             scale.x = 1
  7.         elif not directionX == -1:
  8.             directionX = -1
  9.             scale.x = -1
  10.         $Label.text = (str(collisionX - position.x) + " | " + str(directionX) + " | " + str(scale.x)) # Label is for debugging
Advertisement
Add Comment
Please, Sign In to add comment