Hello
I’m trying to figure out how i would spawn an actor from a list of actors in a specified zone or area
Hello
I’m trying to figure out how i would spawn an actor from a list of actors in a specified zone or area
Hi Telapicus,
I create two array variables; first contains actor classes to spawn (ActorList), second contains places where to spawn random actors (PlayerStarts). I iterate over all PlayerStarts points and spawn random actor. Feel free to post any additional questions here.
Hope it helps!
Thank you very much glad to see such a helpful community and staff here
Anyway for me to adapt that blueprint to randomly spawn inside the navmesh bounds?
Since this question is so well titled and the first thing that google brought up, I thought I’d add to it rather than creating a new one. Firstly, I was able to create a setup for spawning meshes inside a volume as you wanted. Big thanks to Zak Parrish’s tutorial videos! - YouTube
Essentially you create an actor BP with a collision cube for your volume (set collision to none) and a static mesh (or in my case destructible) with nothing set as the actual mesh to use (though you can set a default mesh if you like) and name it something like “BaseMesh” (in my screen its called Asteroid). Then you create a variable of type “static mesh” named “Mesh to Spawn” and click on the grid icon to make it an array. Hit compile and then in the defaults, set all of the meshes you’d like it you use as the “elements” and then Get a reference to the array and plug it into a ForEachLoop. From there you simply Set Static Mesh (in my case destructible) and plug your “BaseMesh” into the target and the Array Element into the New Mesh slot. Picture is worth a thousand words so here’s a screen of my setup:
Now I have a question of my own. This works beautifully for randomizing within the volume, but how would I go about adding more than one mesh to the scene. Essentially I want the number of meshes spawned to fill the inside of the volume with a specific amount of spacing between each mesh. I would imagine that I need to run a get length from my Make Vector node connected to the scaled box extent and somehow use this to set the number of meshes it needs to spawn but I’m not quite sure how to approach it. I’ll play around some more and post back if I figure it out.
I would also like to know . I am currently following a video series where they show how to spawn an object randomly . easy enogh . also i figured out how to spawn many different objects on the same spawn points randomly . the problem is that they sometimes spawn into each other . meaning they look ugly and cant always go past them . so annoying .
Follow the link in my post above and read my post and you should be able to figure it out. If you can’t, let me know and I’ll make a video tutorial.
Question from a super noob: How did you make the Arrays and populate them with the actors?
To make an array of any variable you simply click on the little grid icon to the right of the variable name. This makes it an array variable rather than a single object variable. Compile and Save and then select the new array variable and in the properties windows you can set the default values of the array variable with the actors you want. (click on the plus icon to add more actors to the array)
An alternative method is to place several actor references into your BP and then use a “Make Array” node to store them into an array. Keep in mind you can’t mix actor types in an array. So you can only have an array of apples or an array of oranges not an array of apples and oranges.
I spawned a character but i can’t get it to move and give control to the player, can you tell me how to do it?