Spawning dynamic objects along the circumference of a circle

Hello there!
As the title says, I want to spawn dynamic objects/actors along the circumference of a circle, in Blueprints.

I can imagine how this would work, but I am not sure how to accomplish this in UE4. I’ve made a simple diagram to help me explain myself:

The red dots are of course the objects that will be spawned. I want to be able to dynamically spawn 3, 4, 5 … 8, 10, etc. objects along an imaginary circumference, with the pivot point set in some location in the scene.

I suppose what I need to change dynamically should be the X angle (with a rotation), and also set the length of the circle’s radius, but how? Which nodes should I use?

Can somebody help me achieve this? At least point me in the right direction?
Thanks a lot !

Hope you figured it out, but if not what you need to do is 360 / X. That’ll give you the rotation of where to place all your items. I hope this helps.

Hi, I’ve made a basic algorithm for you. You can define where you want the center, how large you want the radius, and how many to spawn - and it will result in a vector location for each item.

This works by dividing the quantity into a degrees based on a 360 degree circle - because of this you could also adapt it to work in a semi circle by changing to 180 or a quarter circle with 90. Then it multiplies the index by the degrees, so first item is 1 * degrees, second is 2 * degrees, etc. - them it makes a rotator to get the forward vector, which in this case will essentially be the direction it’s pointing it, and multiplying it by the radius moves it along the direction it’s pointing in essentially pushing each location outwards. Then we append the center of circle to position each object.

For previewing purposes I have it connected to a Draw Debug Point, but presumably you would want a Spawn Actor here instead, with the location being fed in.

2 Likes

Ooh man thanks, I’ll try this as soon as I can and let you know how it goes!

1 Like

Exactly what I needed, thanks a lot. :wink:

1 Like

Thank you so much. That’s exactly what I was looking for a while. :smiley:

1 Like

WARNING!!! Make sure to convert the quantity division into a FLOAT or you will get the wrong outcome with certain numbers.