Playmaker Forum
PlayMaker News => General Discussion => Topic started by: RC on May 29, 2017, 07:47:40 PM
-
Hello.
Im trying to figure out how to spawn prefab in a circle. Has anyone successfully done it,that can share how you did it? Thank you.
-
You want to spawn multiple objects into the shape of a circle?
For example: 10 cubes that form a circle?
Then you will need to calculate the x/y/z positions for that circles points prior to the prefab placement. I am not sure playmaker itself can do that, unless you manually calculate them yourself before runtime. Do you need it to be dynamic?
-
Thank you. I was afraid of that. I guess I'll just manually calculate the points for now. I don't think there is an action that playmaker have that can do that atm.
I do need it to be dynamic.
-
Do you need this for 3d or 2d?
What part do you need to be dynamic? The amount of points on the circle or the size of the circle, or where the circle is in the world?
reference: https://stackoverflow.com/questions/24046402/trying-to-spawn-enemies-in-a-circle-around-the-player-in-unity
http://answers.unity3d.com/questions/714835/best-way-to-spawn-prefabs-in-a-circle.html
-
It's for 2d,
the size of the circle.
I will check out the links. thank you.
-
Not sure how good your c# is, but if you want, I can take a crack at it later. I would just change it into a playmaker custom action. (Providing the example code isnt too broke).
-
So from the script above I wrote this action. Maybe not exactly what you need, as the exact position of the prefabs are random (along the circle).
But you can set the radius, and center of the circle (centered around a gameobject), as well as the number of prefabs (and of course what prefab).
-
No way! That's awesome! I can't wait till i get home from work to try it out.
THANK YOU!