OrbitLib: Space Flight Dynamics for Roblox Lua

image
how would i make it go with the red line?
1.5 ecccentricy and 0 inclination right now

Given the example renderer demo, a timeAcceleration of 1 will be real time.

Let’s look at the heartbeat handler:

-- A handler for the Heartbeat event. The argument step contains the time since the last frame.
function OnHeartbeat(step: number)

    currentTime += step * timeAcceleration -- <-- THIS IS THE IMPORTANT LINE

    PositionPartBasedOnPrediction(orbit, spacecraftPart, currentTime)

end

Every frame, we run currentTime += step * timeAcceleration. This says “increment the current time by the time acceleration times the amount of time that has passed since the previous frame.” If the time acceleration is one, then we increment only by the time that has passed since last frame, e.g. real time.

1 Like

What you are trying to do here doesn’t have much meaning or relevance in astrodynamics, but you might be able to achieve it by adding π radians to the inclination.

the weird part is when i put the semi major as -negative,the orbits flip sideways as it the planet is going clockwise(seen from top)
but the spacecraft just doesnt work

See my previous comment on the matter of negative semimajor axis. The library assumes you are giving it values that make physical sense.

For further discussion related to this, please directly message me as we have been inadvertently creating many replies and I would like to keep the forum clean :slight_smile: .

1 Like

Thanks a ton. I got it all working so well. It’s amazing!

1 Like

@Creeperman16487 amazing thing that you did with the slider. Really amazing and creative. Nice work!

Dont credit me for the slider,its a module from devforum its called Slider Module,pretty good stuff

The reason i have sliders is because i wanted to see the orbits before adding them in my game

I did see that the sliders was a module. But how you used the sliders to change the orbit right there.

i just changed a replicated storage value with the eccentricity,semi major etc,then i would just redo the whole orbit again by deleting and creating
if your laggy enough you can see the orbit being destroyed and constructed back with the new data

smth like
local orbit = orbitfunctionhere(orbitdatastuffhere)
–we make the planet orbit and create line

–we do code here to detect when the replicated storage values change
we do
–destroy lines of previous orbit
orbit = orbitfunctionhere(orbitdatastuffherewithnewdata
–we make the planet orbit and create line

i also made a module to shorten the code too
its called OrbitMakers in the game

also i made a triple body system
BestOrbits.rbxl (66.3 KB) (Moon,earth and sun)(can only change earth orbit not moon)

2 Likes

I saw the scripts and knew how it worked. Really cool how you put it all together to make the demo. The OrbitMakers helps a ton especially for newer developers.

1 Like

I didnt actually make it in the intention to help others,it was just for me,putting all the code from the docs into one server script was just too hard for me to understand so i made that,its a pretty bad module but it works,maybe i could make it better if i had time but nah
anyways this is a pic of the moons orbit being traced,pretty cool ngl(trails btw)


i also made this thing where the earth orbit inclination changes slowly and make an entire turn,its pretty cool how messy the moons orbit gets
image

Those pics are very cool and interesting.

sorry to revive a dead thread but
this project got me an internship at NASA lol

9 Likes

congratulations

congrats, thats insane. my guy pulled up to nasa and said “look at my roblox library” and got hired

It’s just like how someone got an internship at NASA from Kerbal Space Program. Except you put WAY more effort. What department do you serve in NASA? (just curious lol) and what do you do?