Looking for a Good Similar Example

I’m trying to migrate from having C++ code controlling a simple Sphere object, to using Blueprint Classes for managing planet orbits. I’m also replacing the Sphere objects with Blueprints for each planet, if that makes any difference.

I’d like to have one KeplerOrbit BP class that can be called by any body and fed Keplerian Elements as variables that can be fed into the OrbitController, and then use that as a means to control the orbit. Also, so that this can apply to moons, I’ll need to set a parent object variable for each orbit.

What would work best, a Blueprint Actor Component, a Function Library, Object casting? It seems like there are a lot of methods, but I can’t quite find the best tutorial for this type of setup.

One option might be, as you say, to have one blueprint that defines a planetary mesh and exposes as editable all the other variables you want to use for your kepler orbits (such as center location, diameter of orbit, diameter of planentary body, mesh texture ,etc), within that blueprint you could then leverage predefined curves that can define a normalized circular or eliptical orbit that you can apply your variables to calculate the spheres positions which can be transformed or rotated further depending on how deep diwn the rabbit hole you want to go

You can them add as many of these blueprints as you wish and just configure the parameters accordingly to get the desired orbit for each sphere

Just so we are talking on the same level here… are you trying to emulate planetary body orbits or simulate? (Ie… whats the precision you are looking for in the application of your orbital calculations… looks reasonable or is calculted precisely)

Will likely impact your decision

Yeah, and probably will break down from one mesh to several so that I can go above 8k texture limit and avoid problems with the poles. So containment in BP is good goal.

The question then is - how does each planet/moon BP access the instructions that calculate the ellipse - where should the Keplerian calc live - a BP Actor-Component, a Function Library, a Macro, I’m just too new with BP and am not sure on how to scope & passing variables works.

And there is bigger issue with wanting to asteroids - with adding closer to 10k instances - simply simulating gravity on those objects may be less taxing.

Thanks for your help!

Definitely simulate, aiming to use Keplerian orbit elements. Scope of map is just our solar system.

In that case, personally I would leave the “crazy” math calculations in a c++ utility class and expose your functions to your blueprints, I’m not sure blueprints are great for complex math.

This can be accomplished by adding blueprintcallable to all the functions you want to expose.

Then you can go with one blueprint per orbital body that encapsulates all the physical representation and variables needed to do the calculations and call your utility class directly.

You can create an instance of your utility class in the construction script of each blueprint or you could have a common blueprint or function library that each blueprint calls to obtain the reference to the utility class