playMaker

Author Topic: How to spawn prefab in a circle?  (Read 1818 times)

rongconcrx

  • Full Member
  • ***
  • Posts: 113
    • View Profile
How to spawn prefab in a circle?
« on: May 29, 2017, 04: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.

tcmeric

  • Sr. Member
  • ****
  • Posts: 480
    • View Profile
Re: How to spawn prefab in a circle?
« Reply #1 on: May 29, 2017, 07:00:43 PM »
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?

rongconcrx

  • Full Member
  • ***
  • Posts: 113
    • View Profile
Re: How to spawn prefab in a circle?
« Reply #2 on: May 29, 2017, 09:56:13 PM »
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.

tcmeric

  • Sr. Member
  • ****
  • Posts: 480
    • View Profile
Re: How to spawn prefab in a circle?
« Reply #3 on: May 29, 2017, 10:10:27 PM »
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
« Last Edit: May 29, 2017, 10:15:53 PM by tcmeric »

rongconcrx

  • Full Member
  • ***
  • Posts: 113
    • View Profile
Re: How to spawn prefab in a circle?
« Reply #4 on: May 29, 2017, 10:25:44 PM »
It's for 2d,
the size of the circle.
I will check out the links. thank you.

tcmeric

  • Sr. Member
  • ****
  • Posts: 480
    • View Profile
Re: How to spawn prefab in a circle?
« Reply #5 on: May 29, 2017, 10:35:42 PM »
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).


tcmeric

  • Sr. Member
  • ****
  • Posts: 480
    • View Profile
Re: How to spawn prefab in a circle?
« Reply #6 on: May 30, 2017, 01:34:32 AM »
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).

rongconcrx

  • Full Member
  • ***
  • Posts: 113
    • View Profile
Re: How to spawn prefab in a circle?
« Reply #7 on: May 30, 2017, 07:04:22 AM »
No way! That's awesome! I can't wait till i get home from work to try it out.

THANK YOU!