class OrbitalSystem extends Engine.System
for entity in @world.getEntitiesWithComponent OrbitComponent
updateEntityOrbit: (entity) ->
position = entity.getComponent PositionComponent
orbit = entity.getComponent OrbitComponent
orbit.angle += (Math.PI / 2) * (1 / orbit.distance)
parentPosition = orbit.parent.getComponent PositionComponent
position.x = parentPosition.x + orbit.distance * Math.cos(orbit.angle)
position.y = parentPosition.y + orbit.distance * Math.sin(orbit.angle)
rsgm123 wrote:Is n-body out of the question? it may make for interesting gameplay, even if it is just for asteroids(if there are any).
r4d2 wrote:I like how the orbits are calculated/simulated in Kerbal. Does anybody have an Idea how they do it?
It' s definitely not n-body. I would guess they basically calculate a perfect elliptic orbit to the closest body (wrt. gravitational force), with some form of interpolation when the forces are almost identical.
Users browsing this forum: No registered users and 1 guest