Alert All Enemies Inside Certain Area
I am trying to alert all enemies inside a certain area when one of them sees the player that they have to move around and try to find the player. What is the best way of doing this? I'm thinking there might be someway of doing this with sendmessage but how do I do it so only the enemies within that certain area are alerted of my presence?
Answer by marfa4321 · Jan 01, 2016 at 07:55 AM
Hi, @L20GAMES
I'm think you can use RayCast and Trigger Collider.
Put an Trigger Collider in your certain area.
Then you check if the player in the trigger collider, you create a code to make RayCast.
While a RayCast got player gameobject, you create a code to moving all of enemies to go to the player.
But to do this, your player must have Collider Component to use Trigger Collider and Tag to use RayCast
If you have a trouble when making the code, you can tell me again
I am a bit confused with this. I've got a thing on the enemies so if the player enters their line of sight it will alert them and they will move towards the player. I need it so if one enemy gets alerted then all the enemies within a certain area get alerted. Sorry if there were any confusion.
Are you mean 'if player enter the certain area' or you mean 'if an enemy seen player in anyplace?' If you mean an enemy seen player in anyplace and then all enemies in certain area will get alerted, are all enemies is static or dynamic? (i mean 'are all enemies is static' is 'all enemies' not increased or decreased and 'are all enemies is dynamic' is 'all enemies' can increased or decreased) I am a bit confused too with this question. Sorry, maybe you must explain it clearly. sorry if my english is bad
Your English isn't too bad :) I am wanting all enemies that are inside a base to be alerted when one of them sees the Player. The only way I can work out to do this is by sending a message to each individual enemy. Is there any easier way to do it.