x

Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

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

alt text

Product Version: UE 4.20
Tags:
bp.png (205.0 kB)
bp2.png (159.6 kB)
more ▼

asked Oct 04 '18 at 01:12 AM in Blueprint Scripting

avatar image

ZoroSama420
1 2 2

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

3 answers: sort voted first

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.

alt text

capture.png (428.2 kB)
more ▼

answered Oct 04 '18 at 01:22 AM

avatar image

ThompsonN13
10.1k 33 9 23

avatar image ThompsonN13 Oct 04 '18 at 01:45 AM

also note i made these scripts in a actor bp so they can be reused as you see fit. you could use them in different levels or have many triggers placed in one level if you liked. if you only needed it for the one level then you could still make it in the level bp if you really wanted to.

avatar image ZoroSama420 Oct 04 '18 at 02:29 AM

Hie How can i make it that the AI's Spawn at all the target points once and thats it , Not random target points

avatar image IndieGameCove Oct 04 '18 at 02:46 AM

that's what his method 1 is doing

avatar image ZoroSama420 Oct 04 '18 at 02:47 AM

Hiee Thank u so muchh , it worked outt , This really helps so muchhh

avatar image ThompsonN13 Oct 04 '18 at 02:51 AM

yea if you want to spawn at all target points in the level then you could use method 1 for that.

method two just shows another method and some optional bits that you can add. theres much that can be done to add customization or many ways to do the basic method your looking to do.

avatar image ZoroSama420 Oct 04 '18 at 02:58 AM

I am Sorry But one Last question how do i assign the AI Controller to them after Spawning , THis doesnt seem to workalt text

cap2.png (73.5 kB)
avatar image ZoroSama420 Oct 04 '18 at 03:04 AM

I tried using the Get all actors from Class , but i cannot set The animation Mode back to the Bp ,how can i find a connection from the array to Skeletal mesh target,alt text

cap3.png (70.9 kB)
avatar image Nebula Games Inc Oct 04 '18 at 03:24 AM

drag off the array output pin and search for "for each loop" then connect the element pin to the skeletal mesh target.

avatar image ThompsonN13 Oct 04 '18 at 03:28 AM

How do i assign the AI Controller to them after Spawning

do your characters not have a ai controller by default? if they arent acting as they would if placed in the level then it may just be the ai default possession, basically theres a option that you need to set to "spawned and placed in level", i odnt have unreal open at the moment so i cant say the exact option but itll be in the class defaults list 2 options below auto posses player.

how can i find a connection from the array to Skeletal mesh target

again something you shouldnt need to do, but the way you could do it if you choose to go that route would be to use a for each loop on the output array then get the skeletal mesh component off the blue array element pin on the loop. depending on your setup you may also need a cast in there to define which class your looking for (cast to character or your specific character class type)

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

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.

more ▼

answered Oct 04 '18 at 01:24 AM

avatar image

ElFab
1 1 2

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

probably worth looking into event dispatchers. here's a link

also this is the best blueprint 101 tutorial in existence. link

more ▼

answered Oct 04 '18 at 01:35 AM

avatar image

IndieGameCove
1.1k 6 4 10

(comments are locked)
10|2000 characters needed characters left
Viewable by all users
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question