A way to have objects Orbit around another actor?

Hello All,

I am making a game for a university project and wanted to ask if anyone has a suggestion on how to implement this mechanic.

What the idea basically is, is that the player is a Stone Sentry that collects gems that improve their attacks. These gems are scattered throughout the world, and when the player collects them they begin to orbit around the centre of the player controller; as a visual indication as to what gems the player currently has.

To be more abstract. I am looking for a way to attach an object to a point and have it orbit around it. in an ideal world the gems orbiting the player will be spaced equally apart.

The maximum number of gems may be 8-10, if that helps.

The easiest way is to add a springarm to the parent object and attach the object you want to rotate to the Springarm’s business end. Its length is the radius. It’s a robust and efficient method.

You end up rotating springarm in place.

That certainly solves part of the issue, however; I feel that I didn’t expand on my issue enough. How would I go about producing a system that will dynamically pick up these collectables and set them in motion around my character? Your method works great if I was to set up my controller by hand and physically attach them in the editor, but my concern lies with while players are running the game.

Basically I need a system that will attach gemstones to the controller while the game runs without having to physically attach things to the actor (like empties) beforehand to make it work. We might decide that the player can attach up to 20 gems to the actor, and we need a system that will dynamically accommodate for that.

Thank you for your response.

Either create the 20 springarms and set it to show or not, or create BP where you have the spring arm and the gem attached to it, on your character create a function that adds or removes that BP to the character. Still the Everynone solution seems to suits you.

Yup, what @Iotti said. Make the springarm the root of the pickup actor.

Alternatively, consider adding components procedurally by spawning them as needed:

215628-capture.png

In case you require something a bit more elaborate and way more flexible, look into splines. Here’s an entry dealing with a very similar issue:

I feel I may need to explore further to find more solutions. This method has helped me in some areas, but I still require a method that will distribute the gems in orbit around the character. Attaching the gems to the player controller isn’t too challenging, but I’m not sure how to have them orbit around the character in an equally distributed fashion. Such as if the player had 3 gems, they would orbit 120 degrees apart from eachother. If there were 4, they would orbit 90 degrees apart, etc etc.

At the moment I have the gems attached to a spring arm around the player, but it looks quite ugly and disorganized since they aren’t equally spaced apart when they spawn in. Placing them in pre-designated spots works to a degree, but it doesn’t seem very polished.

Is it possible to achieve equal distribution this way? or will I have to use a method like “Splines”, as suggested?

I was not seeing the big picture here. I originally thought each element will have a different radius but now it seems they will be sharing the same orbit and need to be spaced evenly. Should have read the original post more carefully:

[…]the gems orbiting the player will
be spaced equally apart.

It can be achieved with a springarm, it’s just a bit of math you apply to offset the initial rotation of the springarm. Let’s say you’ve picked up the 5th gem: 360/5 gives you offsets at 0 | 72 | 144 | 216 | 288. Update all springarms rotations to those values. You may need to interpolate so the newly picked up gem slides neatly into a new position and the others make space for it, too.

However, since the orbital distance is constant (the gems are always at the same distance from the player), you could use a spline. In this case, you’d only use 1, no additional components are necessary. The gems ride along the spline’s length. When a new one is added you get the spline length and divide it by the number of gems. This gives you a new position on the circle circumference for the gem to chase after.

Let me know if I made it sound confusing (my secret talent), I’ll try to drop a blueprint example here later on.

That is fantastic. Thank you very much. This is exactly what I need.

You both helped out tonnes. Thank you very much.

No worries, let me know if you this gives you a headache.

yes, could you please give a blueprint example for the spline method?
i’ve done it with the springarms but the spline method is confusing me.

The examples are there. Follow the link in the post. And if you keep clicking the trail of links, it will eventually get you here:

Not 100% sure what you’re after, hope that’s it.