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?
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.
answered Jan 22 '19 at 01:07 AM
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.
answered Jan 22 '19 at 03:30 AM
Nebula Games Inc
Follow this question
Once you sign in you will be able to subscribe for any updates here