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 actor in TargetPoint near the player

Hello! I'm doing a zombie game and i spawn the zombies randomly between different target points, but i would like to ONLY spawn them in target points that are near the player. Is there any way to do it?

Thank you.

Product Version: UE 4.21
more ▼

asked Jan 21 '19 at 09:09 PM in Blueprint Scripting

avatar image

3 1 1

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

2 answers: sort voted first


You could do a vector length check and if too far away, run the spawn again.

Or you could spawn them in random places within trigger boxes around the character.

Regards Narg

more ▼

answered Jan 22 '19 at 01:07 AM

avatar image

1.7k 74 38 110

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

I would store all your spawn points in an array. Then when you want to spawn a zombie have a function that loops through your array and checks each point against whatever set distance you want from the player. If it is smaller than the max distance add it to a temporary spawn point array within this function (local variable). Once the loop is complete, have it select a random index from the temp array of desired spawn points. Then have a return node return this value from the function. After you can feed that location into a spawning function or spawn from within the previous function if you so choose.

more ▼

answered Jan 22 '19 at 03:30 AM

avatar image

Nebula Games Inc
5.4k 28 9 15

avatar image EMPANADILLA_ Jan 22 '19 at 08:56 AM

Thank you! I'm going to do it with trigger boxes because i have walls and i dont want the zombie to spawn in a different room, but i found your answer very useful.

(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