Documentation
    Preparing search index...

    Function resolveGravity

    • Resolves a world's gravity to the engine's 3D form (§21, Appendix A).

      resolveGravity("2d");                            // (0, -9.81, 0)
      resolveGravity("2d", new Vector2(0, -3)); // (0, -3, 0)
      resolveGravity("3d", new Vector3(0, -9.81, 0)); // as given
      resolveGravity("2d", new Vector3(0, 0, -9.81)); // throws (§21, §85)

      Gravity is negative Y in both dimensions, because §7a puts +Y up in both — a 2D world is not a screen-space coordinate system. Omitting gravity yields Appendix A's default rather than zero, matching §20's and §21's examples.

      A "2d" world rejects a gravity with a z component: there is no third axis to accelerate along, so the caller has either mixed up a convention or built the wrong world, and both are worth an error (§85 "invalid physics dimensions"). Writes into out when given (§7b/D7).

      Parameters

      Returns Vector3