Spawn Multiple actors at target points
Hello , I have 5-6 Target points and i want to Spawn My AI at all of them when entering the trigger box , Right now i have got it working by referencing individual target points , But i am sure there is an easier way , I am super new to blueprint scripting Thank you for your help alt text
asked Oct 04 '18 at 01:12 AM in Blueprint Scripting
all you really need is a reference to the targets you want to spawn at then use a loop to spawn a character at each one. the simplest way to script this is to use the get all actors of class node to get a reference to all the target points and output it into an array. you can then take the array and use a for each loop so for every target point it will run the script after. then just have a spawn actor of class. thats the basics.
now you may want to use other methods to create the array of spawn points such as using a public variable. this method would allow you to have a bp which contains the trigger then to associate specific spawn points for each trigger placed in the level. so if you enter trigger A then enemies spawn at points 1 2 & 3, enter trigger B though and they spawn at 1 2 & 5.
also by using a for each loop rather then making a script for every enemy you want to spawn your script becomes more versatile and reusable.
Edit: below is two examples i what i mentioned. the first one is very basic and will spwan one enemy at every target point in the level. the second method checks to be sure it was the player character overlapping, then gets the spawn points array variable which is public so it can be set on a per instance basis in the level details panel, before finally running the spawn actor between 1 & 4 times per target point. so basically when player overlaps spawn 1-4 enemies per spawn point in the array.
Put out of the first spawnshadow comment (without disconnecting them) all nodes representing something that change from spawnshadow to spawnshadow (for exemple blue nodes). Then select all other node in this comment (node that are redondent) right click and colapse to function. I think after doing that you'll understand (ctrl+w for duplicate) . Also foreachloop can help. Edit: Also the answer from ThompsonN13 is a way to go, but i think you need to understand function as first thing.
Follow this question
Once you sign in you will be able to subscribe for any updates here