Data driven movement

Hi there!! I am using UE4 to visualize orbital mehcanics simulations. My objective is to see the planets and the satellite moving in the space. I have the positions in different times of all the planets and the satellite and I would like to know what is the best option in UE4 to move the corresponding objects according to the data.

Best option will depend on the individual and scope of the project.

What I’ve experimented with:

  • rotating around a vector (clean solution providing you did not skip trigonometry in school and can do semi-advanced stuff)
  • rotating components around other actors and their components using local offsets (feels clunky and a wee bit fiddly but works, not too flexible, though, easy to set up)
  • using a Springarm, which works surprisingly well considering it’s not really designed for this at all - imagine attaching rocks to pieces of string of different length and swinging it like a mad person - that’s how well it works. The Springarms length is your orbital radius here and you rotate the component in place to get orbital movement)
  • settled on using splines, since it also allows to display the orbits at the same time

It works roughly like this:

  • each orbital body is assigned a closed spline (which can shape itself into a tilted ellipsoid and its radius is based on the pertinent body’s desired orbital radius) and is centred on the orbital body’s parent (use pooling here and recycle the splines and their mesh components since moving a lot of them is somewhat resource demanding)
  • each orbital body stores fOrbitalProgressionValue (how far at spline’s length it is) and fOrbitalSpeed (how fast you hurl through space)
  • each orbital body follows the spline’s curvature on Tick by map ranging the spline’s length onto its fOrbitalProgressionValue using fOrbitalSpeed

tl;dr - Planets, moons, asteroids, satellites and whatever needs orbiting are all sliding on their splines. Each object keeps track of how far it is on the spline and how fast it’s going.

This is a completely non-Newtonian approach and has nothing to do with gravitational forces. If you’re after a real simulation - this is most likely the worst possible method.


Better alternatives may exist, like using actual orbital equations. Or simulating physics if you’re after something more arcady.

The position data of all celestial bodies is pre-calculated in Matlab simulator that takes account of all the physics. I only want to visualize that data. I can have the velocity vectors as well. So taking the first option, what do you mean by rotating a vector?. I mean I’m new in UE4 and I don’t know what function does that. In the past I tried to animate an aircraft with simulated data and the motion was very sharpy. I want to see a smooth movement. The best option that i had found was using timelines with loaded curves. Thanks for the help.

[…]what do you mean by rotating a vector?

I meant this:

251044-capture.png

Depending on what data you have, you may not need it at all, though. The question is: what data do you have and what format does it come in? Never used Matlab simulator.

The position data of all celestial
bodies is pre-calculated -

So what is it exactly? An array of points? A vector curve?

The position vector is a vector containing the 3 location components (x, y, z) of a body. As all the bodies are moving in space I have all the different position vectors in the different times. The format of this data can be the one that you want, from matlab I can export to excel, txt, etc… For importing in UE4 I’ve tried loading it in a vector curve but I don’t know if that is the best option.

As all the bodies are moving in space
I have all the different position
vectors in the different times.

Since it’s all pre-computed and you have the specific timing, using Timelines seems like the way to go - you mentioned this yourself.

If you can generate a vector curve for each object, you could have a Timeline in each body and have it set the object’s position directly in 3d space. That would be the most elegant approach. (you’d need to scale the whole thing down a lot)

Assuming you have a ton of data, and can’t afford setting the curves manually one by one, you could export the data to *.csv, and load it into a DataTable in UE4. Each object then can fetch their curve from the DT by name/index and apply it to its Timeline.

Now this is completely untested as I’ve never tried to feed Timelines curves dynamically.

Ok I understand. But why do you say that I need to scale the whole thing down a lot??. Also I want to mention that I want to do this process of getting the external data and loading it on UE4 automatically so I think the best option is to code that in C++, isn’t it?. The idea is to call the UE4 project from matlab and that it passes automatically the directories of the data files, loads them in UE4 and starts the simulation.

Ok I understand. But why do you say
that I need to scale the whole thing
down a lot?

Floating Point Errors.

What I mean is that you can’t use real distances and sizes. 5km x 5km is a reasonable area to work with in UE4. That’s feeble in space scale, even if you use the World Shift Origin feature. Depicting something of real world size is simply unthinkable. Games cheat by scaling things down dramatically. You place objects close to one another but display the real distance on a label.

Also I want to mention that I want to
do this process of getting the
external data and loading it on UE4
automatically so I think the best
option is to code that in C++, isn’t
it?

Automatically is key here - that would require some tinkering and is beyond the scope of what I can do.

On the other hand, once the structs are set up, updating a DataTable from a *.csv file (which MatLab can probably write to) can be done in literally 2 clicks. You could most likely achieve the rest with blueprints bar the last bit:

The idea is to call the UE4 project
from matlab and that it passes
automatically the directories of the
data files, loads them in UE4 and
starts the simulation.

But real scale is possible. I mean obviously as you get away from objects the resolution of textures must be lower but in games like Star Citizen you can approach to planets of real proportions compared to the spaceship. I saw projects doing things similar to what i mentioned like this one:
link text

No. Real scale is not possible. Not with current tech, not in real time, not in game engines, not to the best of my knowledge. Someone please do correct me here if I’m mistaken.

It’s all tricks of the trade. Besides, CryEngine was (very heavily) modified and rigged to use double precision, so they have more wiggle room than us, poor schmucks.

Even for something small, you need World Composition - and that’s to glue a single big island together…

As a test: place an object 1000000 (10km) uu away and you’re fine (physic sim will be unreliable, though), place it at 2m uu you’re gonna have a bad time :expressionless: