Orbit and Gravity Movement Blueprint

Hi, i see that suported platforms are Windows only, but is there a possibility that this plugin could also work on mobile, or if some of the features could work? (iOS, Android)
Thanks!

Nice job! Having written a Keplerian system for a couple of games now I know what a royal nightmare it is, great stuff!

I haven’t tested on mobile, but I can’t think of any issue that would cause it not work on mobile. The biggest concern I would have is that depending on how many objects and calculations you are doing, it could become very processor intensive and a mobile device may not keep up well.

How on earth do i get this?

Will this work in 4.12.2 when i try to get it. It says I have no engine?

Yes - It is now updated with 4.12 compatibility.

For the 4.13 version, there will be a small change to the BPGravityMass function. BPGravityMass will become an ActorComponent, instead of an Actor. That means it will be a lot easier to setup, you just need to add the BPGravityMass as an ActorComponent to your actor or blueprint that you want to have gravity.

Hello, very interested in this plugin, but I am not a physics expert so if this question was somehow answered in the OP then I am sorry.

My scenario that i would like to have orbiting bodies in a multiplayer setting and would like to know if this plugin could calculate orbits based on a time since epoch of the game from a server (planets) and time since entering orbit (ships). The server is not a UEServer so I can’t use replication for this.

That is a good idea, for the next version (for engine 4.15) I will add a property that lets you specify a time for where the actor should begin the orbit. Right now, the plugin defaults the orbit at time = 0, which is wherever the actor is placed when an orbit is initiated.

In the mean time, you could use the attached blueprint to specify a beginning time. Add this to the begin play event for an actor. This example sets the starting point of the actor to the halfway point of the orbit (The orbit period / 2). If you have a server time for how long the world existed, you would need to take that server time and divide it by the orbit period, and the remainder would be the starting point of the orbit. This will only work for the ‘Kepler’ orbit mode.

Thanks, this looks like it should work.

Hello, is this the plugin you use for this?

I saw you have two projects on the store, one that is rated and updated to 4.15 the other is not rated or updated. I’m hoping the updated one (first link below) is what you used for the dynamic gravity.

Yes, that video uses the Orbit and Gravity System (the blueprint plugin that is updated to version 4.15), but also requires engine source modification, so that functionality isn’t technically supported until the engine changes are incorporated into Unreal’s code. A thread discussing the engine changes needed is here: Dynamic gravity for characters - Engine Source & GitHub - Unreal Engine Forums

The other project on the store, Orbital Mechanics and Gravity Plugin, is a C++ version. I created it for performance reasons since the plugin requires a lot of math each Tick, but now that blueprints can be baked into c++ I don’t see any reason to use this C++ version.

The gravitymassactor is not in the project, instead there is a gravity mass component which I assume is used instead that is added to actor blueprints. I’m modifying the source code right now. So the updated 4.15 version in blueprints has all the same functionality as the plugin without requiring the plugin?

Yes - The GravityMassActor was replaced with a GravtyMassComponent that you attach to an actor.

Yes - The blueprint version has all the same functionality.

I’m modifying the source code, any tips on what’s changed in the 4.15 engine code? I’m good at debugging/building so I just need to know what major changes there are from this git changelog (assuming it’s what was used in the dynamicgravity youtube video)

https://github.com/EpicGames/UnrealEngine/pull/1773/files#r45329019

Hey, this looks fantastic.

Just wondering, if I set up a planet to orbit the sun, can I have a moon orbit the planet? And would the planets/moons orbits be affected by the gravitational pull of other planets/moons? Is everything pre-calculated, or if I suddenly dropped in another planet (in real time), would the planets already in the map be affected? I hope I made this all make sense.

Thanks!

You could have a moon that is orbiting a planet, while a planet is orbiting a sun. There are two types of physics modes and the behavior will be different depending on which ones you choose.

In Kinematic mode, gravity is calculated each frame (or more frequently if you use substepping). In this mode, multiple GravityMasses can affect an object that has an OrbitMovementComponent. So a moon can be affected by both its planet;s GravityMass and the sun’s GravityMass. Gravity is calculated in real time, so you could drop another planet into the scene and it would affect the other actors (but you would need to call the function “AddAllGravityMassesInScene” from each OrbitMovement component in order to register the new GravityMass with the orbit component). The downside of this mode is that the physics is calculated at a timestep (like the framerate), and accuracy is directly related to how frequently the physics runs. Orbits in this mode could also become unstable due to variations in how often physics is calculated, or if multiple gravityMasses affect an orbit enough to pull the object out of orbit.

In Kepler mode, a “perfect” orbit is calculated based on two actors only. This orbit will never change and will not become unstable (unless you tell it to change). This mode will keep the same orbit regardless of framerate. In this mode, you would add a planet and set it to orbit the sun, and then add a moon and set it to orbit the planet. The moon will orbit the planet while the planet orbits the sun, but the sun’s gravity won’t be affecting the moon like in kinematic mode. The advantages for this mode is that the orbit is a mathematically ‘perfect’ orbit that will not change based on framerate or physics substepping rate. The downside is that this will only calculate gravity from one GravityMass at a time.

But it is still possible to change for example the distance of these two objects at runtime in kepler mode? and is a function like that already build in or would i need to extend this on my own?

relating to the bp version. Thanks for your answers and your work here :slight_smile:

Yes, in runtime you could move the object to wherever you wanted it, then from BP_Orbit call Init New Orbit with the velocity and start location you want, and it will build the orbit based on those parameters.

Upon request, for engine version 4.16, I have changed the parent class of BPGravtityMass and BPOrbitMovement to SceneComponent instead of ActorComponent. This will allow you to change the point on the actor gravity is calculated from.