I have some general questions about this. I don’t have anywhere near the mathematics skills to handle orbital mechanics, but I have a reasonably good idea what all the orbital elements mean. I can rendezvous with vessels in other orbits in KSP and Orbiter, for example. Things like conic sections and integrators leave me puzzled.
For my little hobby space game, I have a realistic, small pilotable ship floating in zero G near a space station in earth ‘orbit’, but I’m unable to do the maths required to a) have multiple vessels in different working orbits and b) figure out how to fly from one to another.
I just want to be able to use an onboard computer in the ship to calculate new trajectories and rendezvous situations. My main question is, would this product provide everything I need to skip heavy math in this scenario?
Could I easily do things like:
Render an orbital map with maneuver nodes, ascending/descending nodes, and ntercepts/distance between targets ala KSPs map mode?
Use physics thrusters and collisions on my vehicle to move it around in local space, and have these perturbations affect the long-term orbital movement (ie, if I’m departing from a space station slowly, i expect to rotate around the station as we progress around the orbit) ? I am very interested in this scenario.
Given a position and velocity, can I get data to draw the future path of this object on a map?
Calculate a gravity-assist flyby if i was in a system with multiple moons ?
Is it easy to speed up simulation time, when player wants to fastforward to their destination?
How do you suggest integrating this library with game scale? I’d like my game to go from low earth orbit to lunar orbit, (possibly around saturns moons too), with realistic numbers visible for all distances, velocities and times. Do you use doubles? Do I just scale everything down by some orders of magnitude, and fake the numbers in the UI? How would this affect the use of PhysX thrusters and mass?
I don’t expect this product to do all the work for me, but I’m really hoping it’ll help me avoid all the maths involved… your comments would be very appreciated. Just talk around these areas and try sell me the product
Are there any examples or documentation I can browse to get a better idea of the contents?
The first video on this thread has some examples you can look at, and also lists the functions. I think this plugin would help with some aspects of what you are trying to do. It will do a lot of the orbital math required, but you would still have lots of blueprint integration and development to do. You would probably have to modify some parts of the plugin to make it compatible with what you’re trying to do. I havn’t played KSP so can’t comment on if it can recreate some of its features, but Ill try to answer your questions:
There is a function that draws a spline for an objects orbit, and functions that provide a vector to ascending and descending nodes. For distance between two objects, there are not any built in functions that compares two orbits to get a closest approach or intercept distance.
-You can add movement to an orbiting object and have it affect the orbit.
-You can get data to draw the future position. There is a “FuturePosition” function, and a blueprint that draws a spline for the entire orbit. (Futureposition won’t be completly accurate in Kinematic mode, and will only calculate the effect based on a single gravity body).
-Check out post #37 for info on multiple moons. You would need to use different kepler modes depending on the behavior you want.
-Yes, you can change the simulation time
-For different scales, I think the best idea is to use multiple different maps. The plugin does not use doubles, since they are not supported by Unreal.
I am still very confused about the scale though… What scale can this handle? I hope to be able to make small, cm/s movements with thrusters, but have this movement influencing the other side of the orbit… and as mentioned, my vehicles should make the correct relative movements around each other due to the orbital position. I dont know how to approach faking this, and any advice would be very welcome indeed
The plugin works on the same scale as Unreal Engine, which is limited to floating point precision. You can have an object that has a thruster, and the plugin will change the orbit when the force is added.
You can have small changes, but everything depends on your world’s scale. The plugin will operate with the same limitations as Unreal engine world size.
An orbital mechanics library which can’t handle the size of an orbit isn’t really all that much use to me to be honest. Can you speculate on how easy or difficult it would be to replace the floats in your code with doubles, if i used the C++ version of your library? Obviously I’d need to convert to float when updating object positions, but internally to your code would this be an easy change and still keep the precision of the orbital maths?
My primary reason for double precision is to have two ships which can maneuver near each other with PhysX thrusters and cm/s speeds (like for docking and undocking), yet any physx collisions, or just the general small changes to velocity should be propagated over the entire orbit, so that when time is accelerated, the ships move with the correct relative motion (spiral around each other).
Also, could you confirm the following for me… if i put in a central mass of 20,000,000,000,000,000 kg, for an orbital radius of 7km, this should work just fine within UE4? I would get an orbital period of 53mins, and I could have my spaceship with realistic mass, physx collisions, and thrusters nudging it around and have everything behave well within the range of floats? And if I accelerated my ship so that the orbital radius grew to 10 or 15km, what sort of behavior would I see as the floats lose precision?
For your scenario, I would suggest using 1 unreal unit = 1 meter, so the orbit radius would be 7000 units. The plugin works as expected with those values (the plugin uses GM, which is Mass * the universal gravity constant, so you would use a GM value 1335000 instead of 2x10^16kg). If you place an actor at x=7000, and use a gravity mass of 1335000, you will get an orbit with a period of ~53minutes, and 7000 unreal units is a reasonable distance for movement to appear smooth. If you apply an acceleration to the orbiting object, the orbit will change as expected.
Ok, thanks. What about my other question, if I got the c++ version, what’s involved in changing the floats to doubles, or some arbitrary precision library? Is that a trivial change?
With blueprint nativization available, I don’t see any compelling reason to use the C++ version, and I’ve taken it off of the marketplace.
Changing to doubles would give you some increasing precision in internal calculations, but just changing the floats to doubles won’t be an adequate solution for your scenario because you would still need to convert back to floats for use in the engine.
hey @dingtech
Just upgraded this to 4.17 and I’m wondering how to utilise this http://prntscr.com/gcw1zp
I was thinking about feeding in list of actors with Mass Gravity components and the Orbit Movement Component could pick the largest influence but not sure how to do it ?
For the Gravity Mass Array, feed it a list of Gravity Mass Components (not the actor) that you want to affect this instances OrbitMovement Component. If left blank, it will default to all GravityMass objects in the scene. This is only used in Kinematic mode.
To select the largest influence, you will need to loop through every Gravity Mass, check the gravity acceleration exerted by using the Gravity Mass “Gravity Acceleration Exerted” function, and send whatever has the largest value to the Gravity Mass Array. There is an example of how to do this in the SetGravityMassOrbitingToLargestInfluence function inside BP_Orbit (that function is used by default when using Kepler physics mode).
For version 4.18, I will add a function called something like GetLargestGravityMassInfluence to make this a bit easier.
Hey @dingtech
I’m trying to display the current velocity of my orbiting object in m/s. That’s what I do:
Get Length of the velocity vector (from OrbitMovement or PawnMovement Component)
Divide the length by World Delta Seconds to get units per second
Divide by 100 (1uu = 1cm)
My issue is, the numbers are kind of jumpy, no matter which mode I choose. For example, my PrintString would show once per second:
362.765503
356.096924
384.223663
374.520538
371.513519
356.24231
352.901398
364.238708
I was expecting a more stable velocity (on a stable orbit) and smoother changes. Do you have any idea why the velocity is so jumpy or an advice on how to smooth out the numbers, so the player wouldn’t freak out watching his velocity go up and down?
@SONB I believe the issue is that you are actually calculating acceleration, not velocity. At step 1, the velocity vector length is already in units of uu/sec. Your step 2 puts it in units of uu/sec^2. So all you need to do are steps 1 and 3 to get m/s.
When I print the velocity vector length using the Start Circularized option to create as close to a circular orbit as floating points will allow, the velocity stays very steady for me in each physics mode. When not in a circular orbit, the velocity does change as expected.
Oh boy, that’s embarrassing…
Now my velocity is smooth as butter. Thanks a lot!
I have one more question: I want my orbit spline get updated when I thrust. Right now I’m using your DrawOrbitSpline function on EventBeginPlay and a modified one on EventTick, in which instead of spawning a new spline I iterate through all spline points of the existing one and set their new location, retrieved from the Orbit class, with SetLocationAtSplinePoint. Is that the correct approach or should I do some additional stuff with the plugin?
And there is some minor ‘issue’. I’m not sure because even if I spawn the spline with your DrawOrbitSpline at BeginPlay and don’t update it, my orbiting object is always offset by ~1m outwards the orbit spline. It might at some point in time move back to the spline, only to leave it again maintaining a ~1m offset. Not a big deal for me, if you’d say that this is a normal behavior.
Oh and, thanks a LOT for this amazing plugin! One of the greatest on the market.
Hi there, I just bought this product and I love it so far from the videos…HOWEVER, when i try to drag n drop a gravity component into the scene i keep getting a “not allowed” symbol… not sure how to get around this… I’m using 4.17… please help!
Have to add them to actors. BP_GravityMassComponent goes on the actor you want to generate gravity and BP_OrbitMovementComponent goes on the actors that you want to be influenced by that gravity. You can have more then one actor using the BP_GravityMassComponent at one time in the map.
Will this work on Mac? You mentioned the intended platform is Windows so I wanted to be sure it will work on Mac.
Will the blueprints provided work in a top-down game or twin-stick shooter like in the templates UE4 provides? I don’t want the gravity to attract the actors on the Z or Y axis.
Does this work with the latest very of UE4?
If an object crashes into an actor that is parented to the actor it’s orbiting will that change its orbit vector? Or is the actor fixed to its orbit path.
Do you think it’s possible to create a blackhole with this plugin? Where all objects within a certain range of the hole will be sucked into a spiral death?
I can’t think of any other questions but your plugin looks very impressive!
I was trying the rolling ball video, and I can’t find the Gravity_MassActor in your plugin?? please help!! I bought this thinking I could have it help me make a planet with rotational gravity for vehicles, yet I can’t seem to make anything work? Please help!!