As the title says, I’m trying to make the guard behavior a bit richer. The solution in the video works for outdoors and open spaces, but if the scene is in, say, a dungeon, I found that guards can catch you and come after you even if you are walking in the corridor outside their room, for example. Rather frustrating gameplay when enemies you have not even seen yet attack you, and it also limits level design options.
My solution was to add a collider to every relevant object in the scene, then raycast from guard to player and see if it hits anything before reaching the player.
It sounds rather expensive and I’m worried what would happen if you have an actual game scene with dozens of enemies, NPCs and the likes rather than this triny sandbox.
Is there a better way to achieve this?
Also, bonus question: speaking of stuff being expensive, I found that one of my main problems is actually understanding how bad something is in terms of performance, and that’s a serious limit when it comes to my own experiments and projects. I’m always scared that anything I add, whether it is level geometry, terrain size, props/decorations, behavior scripts, whatever, is going to bog down the whole thing and slow it to a crawl. Is there any good rule of thumb to learn? Or good resources to learn from? Thanks!
EDITS: fixed spelling mistakes, because proofriding before hitting send is too smart for me