Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

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.

Product Version: UE 4.16
more ▼

asked Oct 03 '17 at 04:51 PM in Blueprint Scripting

avatar image

168 8 16 19

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

1 answer: sort voted first

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.

more ▼

answered Oct 03 '17 at 04:53 PM

avatar image

15.2k 77 25 62

avatar image Raxs_Slayer Oct 03 '17 at 05:56 PM

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.

avatar image Iotti Oct 03 '17 at 07:10 PM

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.

avatar image Everynone Oct 03 '17 at 07:31 PM

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

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

alt text

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:


capture.png (22.1 kB)
avatar image Raxs_Slayer Oct 03 '17 at 11:11 PM

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?

avatar image Everynone Oct 04 '17 at 07:52 AM

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.

avatar image Raxs_Slayer Oct 04 '17 at 09:42 AM

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

You both helped out tonnes. Thank you very much.

avatar image Everynone Oct 04 '17 at 08:29 PM

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

(comments are locked)
10|2000 characters needed characters left
Viewable by all users
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question