Orbit and Gravity Movement Blueprint

Hi,

I’d like to know how I can force an Orbit Movement Component to jump to a specific position (true anomaly) in its orbit, in real-time, with this plugin.

What I’m doing is that there is an orbiting object, and after some user interaction, I want to be able from my blueprint code to force this object to be somewhere else in its orbit while maintaining all the other orbit properties.

I’ve tried to set the component’s true anomaly value, but it doesn’t change the position. See attached blueprint screenshot.

Thank you!

Assuming you are using the Kepler physics mode, the orbit location is driven by the Orbit’s “Time Since Periapsis Iterator”. You could set that variable to force the actor to be in a certain position. For example, to set an actor to be halfway through an orbit, you could use the GetPeriod() function divided by ‘2’, and set that value for the Time Since Periapsis Iterator (see post 39).

If you want to use true anomaly, there is a function in the orbit object component called “Get Relative Position From True Anomaly” which will give you the relative orbit location based on a true anomaly. You can take that relative location, add the location of the central body to get the world location, then use Set Actor Location to change the actor’s location. Youll probably want to deactivate the orbit component so that it stops trying to update the actors location also. Ive attached an example that moves the actor to true anomaly 0, when a key is pressed, then resumes the orbit when the key is released.

The GravityMassActor has been replaced with a GravityMass component. Just add a GravityMass component to any actor you want to have a gravitational pull.

One thing to note though is that making a planed like gravity for a skeletal mesh like a vehicle will probably not work, or at least be very difficult to implement due to a lack of custom gravity direction in Unreal. If Unreal adds support for custom gravity direction then I will integrate it into the plugin.

Sorry for the delayed reply, my notification was not working.

  1. I am unsure if it will work on a Mac, I dont have access to a Mac to test. However I am not aware of any windows specific features the plugin is using.

  2. The blueprint should work with those templates.

  3. I generally am able to update the plugin within a couple weeks of the latest unreal version.release.

  4. I leave it up to game creator’s to handle collisions. By default the actors will keep going along their path, but you could implement a different collision behavior by creating a new orbit after a collision with a new velocity direction that you specify.

  5. Yes, that would be fairly easy. Just create an actor, give it a gravitymass component with a large GM value, and implement collision so that when an actor reaches the center it is killed.

Is that possible to create cylinder gravity? I mean i want to walk on the cylinder surfaces and simulate physics, can I do that with this plugin easily?

If the cylinder is a static mesh, the plugin has an option called “Use Closest Point on Static Mesh”, which will use the closest point on the static mesh to calculate gravity instead of the center of the object. Using that option you can have an object have a gravity force towards the cylinders surface instead of the center of the cylinder.

However, at this time having a pawn walk along a static mesh is not supported by the plugin. That would require the gravity direction to be modified at a lower level directly in the engine source code. There are a couple of threads in the engine source forum section where people have tried to do this.

Hi @dingtech.
Let’s say I have two space station modules (both in kinematic mode). I want to dock (attach) one module to another.

On attaching, should I:

  1. just disable ticking of the component on the attached module?
  2. move the ticking component to the center of mass of both modules?
  3. do anything else?

On detaching (undocking), should I:

  1. enable ticking of the component on the detached module?
  2. call InitOrbit on the detached module?
  3. The detached module needs to inherit the velocity of its parent module. How can I do this?

Your project sounds interesting! I think you have the right idea.

On Attaching, I would

  1. Deactive the OrbitMovement component of the attached module.
  2. Adjust the OrbitMovement component of the parent module to the new center of mass.

For Detaching

  1. Activate the OrbitMovement component of the detached module.
  2. On the newly detached module, call OrbitMovementComponent->Orbit->Init New Orbit, using the world position of the detached module and the velocity of the parent module (not relative velocity, OrbitMovementComponent->Velocity gives you the world velocity) of the parent module. This will set the velocity of the parent module.
  3. Readjust the OrbitMovement component on the Parent module to the new center of mass now that the module detached.

Yep, that’s exactly the bit I was missing. Thanks a lot!

I have created a new tutorial covering how to setup a Sun / Planet / Moon system, where there is a planet that is orbiting a sun, and a moon that is orbiting a planet.

Feature Request:

The support of TLE data format “Two-Line Element” that is the defacto format that NASA and other entities use to predict where a satellite should be - the predicted location. CelesTrak: Current NORAD Two-Line Element Sets

1 Like

Hi! Assuming this is still active, is there a way to draw predicted paths for objects ahead of them?

Yes, there is an example blueprint function that will draw a spline around the projected orbit path.

In a solar system example, is this capable of having a character run around the surface of a planet, fly off that planet (assuming they are superman) and land onto another planet able to roam its surface?

Having a pawn walk along a sphere is not supported by this plugin because the gravity direction of skeletal meshes requires engine code changes to make walking physics work correctly. You can use this plugin to give PlayerPawn’s an orbit and be affected by gravity, but they will not be able to walk along a sphere.

This plugin may be what you are looking for: Directional & Planet Gravity in Code Plugins - UE Marketplace. You could possibly combine these two plugins together but I haven’t experimented with that myself yet.

This is the exact plugin I am currently using. It works well so far, but once adding movement to the planets, the AI pawns slowly slip off the planet surface while continually being drawn back in by the gravity. Some of them get stuck in falling animation. The player pawn is able to run around no problem, with a few camera glitches every now and then as the location and rotation of the planet update.

Right now, my planets move with simple circle and ellipse formulas to calculate rotation and location based on current time. Each orbit or rotation has a set number of seconds it takes for a cycle to complete, so based on current time, I can tell how far along the cycle it should be and set it to that location and rotation.

My overall goal is to be able to procedurally create a 3D solar system filled with AI actors going about their business on planets, moons, asteroids, space stations, etc. I may end up scrapping the whole 3D concept in the end as it will make other calculations much more complex than they need to be. I might just “fake it” like other games do. Make space 3D, but the planets are actually separate levels that load as you fly towards them.

The best way that I can think of to do is is to:

  1. In a new function, first save the actor’s current velocity.
  2. Call BPOrbitMovement->Orbit->InitNewOrbit, and input the actors current location and the new velocity that the deltaV change will bring.
  3. Call DrawOrbitSpline to draw the new velocity.
  4. Call InitNewOrbitAgain, but this time with the saved velocity to return the orbit to the saved value.

Here is an example where I draw an orbit with a 30% increase in velocity:

](filedata/fetch?id=1815861&d=1601158372)

This is a bit clunky, so for the next version Ill update DrawOrbitSpline to take in an Orbit as a parameter to make things a little cleaner. Then you will just need to copy the actor’s Orbit to a new Orbit variable, call InitNewOrbit on the NewOrbitVariable, and draw the outcome of the NewOrbitVariable.

As a follow-up to this question, will the orbit path update each frame (or something close to) for changes? For example, if the player applies forces to a pawn via input actions, will the orbit spline update? Also, will that orbit spline reflect closed or open orbits as the player makes input changes?

See post number 77 for information on updating an orbit based based on changes in force.

The DrawOrbitSpline function does handle open and closed orbits.

For the 4.26 update, I’ve added an input parameter to the DrawOrbit function allowing you to specify a DeltaV vector to see how the orbit would be altered with the DeltaV specified.