BabylonJS/Babylon.js · error

No Physics Engine available.

Error message

No Physics Engine available.

What it means

The PhysicsConstraint constructor (v2 physics API) requires a physics engine already attached to the scene. Babylon.js stores the engine on the scene (created via scene.enablePhysics()); if absent, the constructor throws rather than silently creating a non-functional constraint.

Source

Thrown at packages/dev/core/src/Physics/v2/physicsConstraint.ts:51

     */
    public _initOptions?: PhysicsConstraintParameters;

    /**
     * Constructs a new constraint for the physics constraint.
     * @param type The type of constraint to create.
     * @param options The options for the constraint.
     * @param scene The scene the constraint belongs to.
     *
     * This code is useful for creating a new constraint for the physics engine. It checks if the scene has a physics engine, and if the plugin version is correct.
     * If all checks pass, it initializes the constraint with the given type and options.
     */
    constructor(type: PhysicsConstraintType, options: PhysicsConstraintParameters, scene: Scene) {
        if (!scene) {
            throw new Error("Missing scene parameter for constraint constructor.");
        }
        const physicsEngine = scene.getPhysicsEngine();
        if (!physicsEngine) {
            throw new Error("No Physics Engine available.");
        }
        if (physicsEngine.getPluginVersion() != 2) {
            throw new Error("Plugin version is incorrect. Expected version 2.");
        }
        const physicsPlugin = physicsEngine.getPhysicsPlugin();
        if (!physicsPlugin) {
            throw new Error("No Physics Plugin available.");
        }

        this._physicsPlugin = physicsPlugin as IPhysicsEnginePluginV2;
        this._options = options;
        this._type = type;
    }

    /**
     * Gets the type of the constraint.
     *
     * @returns The type of the constraint.

View on GitHub (pinned to 0592b347b8)

Solutions

  1. Call `scene.enablePhysics(new Vector3(0,-9.81,0), new HavokPlugin())` (or the v2 plugin of your choice) before constructing the constraint
  2. Verify the scene instance passed to PhysicsConstraint is the physics-enabled scene, not another scene
  3. Check that physics initialization (e.g. async Havok wasm init) has completed before creating constraints

Example fix

// before
const constraint = new PhysicsConstraint(Physics6DoFConstraint, options, scene); // throws
// after
scene.enablePhysics(new Vector3(0, -9.81, 0), new HavokPlugin());
const constraint = new PhysicsConstraint(Physics6DoFConstraint, options, scene);
Defensive patterns

Strategy: validation

Validate before calling

if (!scene.getPhysicsEngine()) {
  throw new Error('Enable physics before creating constraints: scene.enablePhysics(gravity, v2Plugin)');
}
const constraint = new PhysicsConstraint(type, options, scene);

Type guard

function hasPhysicsEngine(scene: BABYLON.Scene): boolean {
  return !!scene.getPhysicsEngine();
}

Try / catch

try {
  const constraint = new PhysicsConstraint(type, options, scene);
} catch (e) {
  if (e.message.includes('No Physics Engine')) {
    scene.enablePhysics(new BABYLON.Vector3(0,-9.81,0), new BABYLON.HavokPlugin());
  }
}

Prevention

When it happens

Trigger: Calling `new PhysicsConstraint(type, options, scene)` on a scene where `scene.getPhysicsEngine()` returns null/undefined — i.e. `scene.enablePhysics(gravity, plugin)` was never called (or was called on a different scene).

Common situations: Forgetting to enable physics before creating joints/constraints; creating constraints in a scene copy or loaded scene different from the physics-enabled one; disabling physics via `scene.disablePhysicsEngine()` earlier.

Related errors


AI-assisted analysis of BabylonJS/Babylon.js@0592b347b8 (2026-08-30). Data as JSON: /api/errors/22f17a77e2642b0f. Report an issue: GitHub.