How to make an enemy shoot at a certain point in PathFollow2D

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By WeezyBee

How would I make an enemy shoot at a player at a certain point of a path when using pathfollow2D?

Is your question:

  • How to trigger something (a shot in this case) at a specific point along the path?
  • How to make the enemy shoot at the player?
  • Both?

jgodfrey | 2020-12-02 03:05

:bust_in_silhouette: Reply From: avencherus

You can monitor the PathFollow2D for that information. The offset is the distance along the path.

if(pathfollow.offset > MIN_SHOOT_DIST)

Or if you know the normalized value you like, the unit_offset could be used in place of that.

If you’re looking for an X, Y position, you can grab the PathFollow2D’s global_position, and check if that’s within an area or range that satisfies the goals of the AI.