Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | Decomius |
How do I make my enemy detect the player from a certain distance?
This is how my tree looks like
I originally tried using Raycast 2d to detect the player, but it detects not only the player, it also detects other things such as walls too.
I’d like some help on a way to do it in a more efficient way. If it matters, the game is a 2D platformer.
Thanks, if I wasn’t clear enough ask me bellow and i’ll try to explain it better.
psuedo code
distance = enemy_position.distance_to(playerposition)
if distance < trigger_distance:
do something
razah | 2018-02-13 07:59