Orbital Mechanics and Gravity Sandbox Plugin

2 March 2-16 Update: Released!
Support thread available at https://forums.unrealengine.com/showthread.php?102660-Orbit-and-Gravity-Movement-Blueprint

The orbital mechanics and gravity plugin lets you quickly simulate orbits, do orbital mechanics calculations, and experiment with gravity sandboxes in unreal engine. Add GravityMass components to actors you want to have gravity, then add OrbitMovement components to actors you want to be affected by the GravityMass components. The plugin then generates an orbit based off the location and velocity you provide to the OrbitMovement components, and the gravity strength of the Gravity Mass components. You can then have your actor move along the orbit, obtain orbital mechanics parameters, and do orbital mechanics calculations on the actors. Includes a Character OrbitMovement component for networking and character code to be included.

Handles Elliptical, Parabolic, and Hyperbolic orbits in three types of physics calculations modes. Physics substepping supported for the kinematic physics mode. Also has “AntiGravity” mode. Source code included!

Video link:

Physics Methods
Kinematic: Updated locations and velocity every frame based on every GravityMass component in the scene. Can be run in realtime or with a specified step time. Physics substepping supported.
Kepler: Generates a mathematically precise orbit based on a single GravityMass. Can be run realtime or a specified step time.
Blended: Uses kinematic physics for an estimated position, then kepler physics for a precise distance for that location. Slightly more efficient than kepler mode.

Functions
-Calculate the future position of the orbit based on a specified time difference
-Calculate the future position of the orbit based on time since periapsis
-Orbit distance based on a specified true anomaly or eccentric anomaly
-Orbit position based on a specified true anomaly
-Get the true anomaly at a location
-Get eccentric anomaly at a location
-Get mean anomaly at a location
-Get a true anomaly from an eccentric anomaly
-Get an eccentric anomaly from a mean anomaly
-Velocity at a orbit location
-Velocity at an orbit true anomaly
-Get the orbit normal
-Get a vector that would generate a circular orbit
-Get a vector pointing to the orbit’s ascending node

Orbit data available
-Gravity direction and magnitude
-Relative orbit velocity
-Eccentricity
-Orbit type (Elliptical, hyperbolic, parabolic)
-True anomaly
-Mean anomaly
-Eccentric Anomaly
-Inclination
-Angular Momentum
-Mean motion
-Specific Orbit Energy
-Semi Major axis
-Semi Latus ******
-Period
-Periapsis
-Apoapsis
-Time Since periapsis
-RAAN (longitude of ascending node)
-Longitude of descending node
-Argument of Periapsis

The only thing we need now is a space game kit :smiley:

Looks good.

I am a simple man: I see a well thought-out and meticulously executed project - I support it.

Good job!

I don’t understand what half of those features mean but it all sounds amazingly detailed. Really hope it get’s to marketplace fast!

Play some Kerbal Space Program, you will!

I do play it but not to such a degree. Like I’m not sure when and where would I use “Get an eccentric anomaly from a mean anomaly” :smiley:

I love it. Take my money.

Could you use this to create a game like Kerbal Space Program? Is it optimized well enough?

Got a few questions -

  1. Would it be possible to make this work with Paper2D or does it already work with paper2D?
  2. Would this work with 2.5D Environments?
  3. What will be the price?
  4. Does this work in a Multiplayer environment?

Just curious

Hi phantom530, could you explain more specifically what you mean by ‘optimized’?

I’ve never played Kerbal Space Program, and don’t have no insight into how its coded. Looking at the KSP YouTube videos though it looks like the plugin will at least do needed things like move your spacecraft actor along an orbit, predict what the spacecraft’s orbit will be, as well as give you the orbital elements. You would probably want to use the ‘kepler’ physics mode because you would want a mathematical representation of an orbit that won’t degrade over time or depend on framerate/deltatime. If you switch to kinematics mode you can apply an acceleration (aka delta v), then switch back to Kepler when the acceleration is over. You would have to make the user interface that applies all of the math and calculations, of course. And probably develop some method of tracking how much ‘delta v’ your spacecraft has.

Good questions…I believe it will work in those environments, but let me do some testing to make sure and Ill get back to you.

Thanks for the answer. By ‘optimized’, I mean could your system support multiple planets, moons, comets, satellites, rockets, etc. at the same time without having too much strain on the computer, and definitely without crashing? I’m surprised you haven’t played KSP, but I highly recommend it :D.

Also, I second HeadClot’s question about whether this works with Paper2D.

Paper2d - Yes, this will work with Paper2d objects.

2.5d - Yes, will work with 2.5d environments.

Price - I don’t have a finalized price yet. I’d like to see how other code plugins with full source are priced in the marketplace, right now there isn’t much data available. I think there are other code plugins submitted before this, so if this plugin is accepted, I will probably use the other code plugins as datapoints to figure it out.

Multiplayer - Yes, will work with multiplayer.

Regarding the optimized question, I ran a test to see how many objects the plugin could support. The test used kepler physics mode with spaceships orbiting a planet, while the planet orbited the sun. The spaceships included a blueprint that matched the spaceship’s rotation to its relative to planet velocity, and turned collision off. My test system has a i7-4720HQ @ 2.60Ghz. The video below shows 160 objects, it ran well at 60fps in the viewport as well as 60fps in the standalone window. With 410 orbiting objects, FPS while running in the viewport fluctuated between 20-40fps, but stayed at or near 60fps in a standalone window. With 1000 orbiting objects, FPS stayed near 20fps in the viewport, and around 40fps in the standalone window. Im not sure if FPS was limited by the plugin, graphics rendering, or other factors. The system did not crash while running any of the tests.

Now submitted: Blueprint version!

How do you draw orbits?

To draw the entire orbit, I think the best way would be to use a loop to query for a couple points along the orbit at evenly spaced intervals, then draw a spline around those points. I don’t have that included in the initial release (the ability to find points along the orbit is included), but I can add that capability for a later release if there is interest. Or maybe do a video tutorial showing how to create the loop and spline with the initial release.