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.
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.
HI
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
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 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.
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.