Playmaker Forum
PlayMaker Help & Tips => PlayMaker Help => Topic started by: ilovelessons on April 08, 2017, 06:15:40 AM
-
hi,
does anyone know how to spawn an object randomly around a certain area.
I have an object and I want it to spawn out of thin air (like 3 or 4 at a time) are a certain area. I didn't see any on Ecosystem... or maybe I missed it..
Thanks guys :D
-
I think you are looking for the "Create Object" action. It can spawn objects into the scene, from prefabs or objects within the scene. This can take a variable, so you can setup a variable here and assign it various prefab objects. Or you can use the "Get Random Object" action to choose a random object with a specific tag.
"Create action" can also take a position (vector 3) variable. If you need a random location, you can use the "random float" action. Change those floats into variables. This way, you can constrain the area.
I have a tutorial on placing random trees, which may help you out. It shows how to generate random floats and change them to vector 3s, so you can have things generate within a specific area. . Its pretty close to what you are thinking, except that my objects are not randomly chosen.
-
Thanks,
I am looking at it now... thanks :D