Projectile arcs: real gravity, every planet at once

How arcs work?

- One gravity model for everything. Projectiles, mines, players knocked into flight and the aim preview dots all step their velocity through the same class, `GravityVelocity`.

- Every planet pulls at once. Each physics step adds the summed pull of every planet in range to the velocity, in full. Surface gravity falls off with the square of distance out to each planet's gravity radius.

- Arcs follow from the physics. Launch power, angle and how close a shot passes a planet decide where it goes. A shot can slingshot round a planet, and a slow, close pass can loop all the way round it.

- The preview matches the shot. The aim dots run the same steps as the projectile, so the arc you see is the arc you get (until the terrain changes under it).

- Per-weapon weight. `gravityInfluence` scales the pull: Bomb 1.6, Cluster 1.3, Missile 1.0, Drill 0.8. Same aim, different weapon, different arc.

The code

public class GravityVelocity
{
    public Vector2 Current { get; private set; }

    public void SetBase(Vector2 velocity) => Current = velocity;

    public Vector2 Accumulate(Vector2 acceleration, float deltaTime)
    {
        Current += acceleration * deltaTime;
        return Current;
    }
}
Next
Next

Day/night shadows: is every phase realistic?