|Topic was automatically imported from the old Question2Answer platform.
So I want my enemies to react when a player is near, either change animation, attack etc. With multiple enemies active at the same time, I’m wondering what’s more efficient:
- In each enemy’s code find player node and calculate distance every frame or
- Add an area to each enemy and use the on area entered signal/function or
- Some other way?
I’d just like to know what’s more efficient in Godot and when does it start to matter, as in how many objects like this would there have to be in the scene for it to start significantly affecting performance.
Area nodes could be used to detect the player, and have the enemies react to the player’s movements. The enemies could also have field of views which can detect the player. There’s an example of this in the Vector math article on the dot product.
Ertain | 2020-05-23 23:16