What is the best method for noticing enemies?
Hello and thanks in advance for helping or at least trying. First question here, so excuse me if I do something wrong.
I am creating a 3d game in which different factions fight each other, all NPCs. So I need them to have some type of "sense"(all mixed in 1) that goes from the player to a certain radius. I know there are some tutorials out there and I have seen them, the problem is that I haven't found one that uses the type of method I am trying to do. I have a NPC(imagine it as a sphere), what i want is to cast a sphere from the bounds of the NPC and expand it till a certain radius. Whatever is in that radius expansion can be "sensed". The problem I have is that sphereCast() doesn't work as I want. It's like throwing a ball to a direction. I don't want the sphere to move, I just want to scale it, bigger in this case, so I can tell what the NPC can "sense". After watching some forums and the tutorial "Stealth game tutorial - 403" I see two options: use the FindAllObjectsWithTag() and check distance with all of them or create a sphere collider around the NPC that will act as my "sense zone" and whatever enters is "sensed". The question here is which one you think would be more efficient for my type of game? In my game I'll have lots of NPCs, hundreds or thousands if possible, so I need the search to be the most efficient. I think the collider option can be better cause it will not look at all the objects the scene has, only the ones in the collider. But maybe FindAllObjectsWithTag() is really efficient and will do it better. Which one you think is the best? Any new ideas?
Thank you.