{"record":{"id":"bedb0075a1cafbab","repo":"BabylonJS/Babylon.js","slug":"no-physics-plugin-available-bedb00","errorCode":null,"errorMessage":"No Physics Plugin available.","messagePattern":"No Physics Plugin available\\.","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/dev/core/src/Physics/v2/physicsConstraint.ts","lineNumber":58,"sourceCode":"     * @param scene The scene the constraint belongs to.\r\n     *\r\n     * 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.\r\n     * If all checks pass, it initializes the constraint with the given type and options.\r\n     */\r\n    constructor(type: PhysicsConstraintType, options: PhysicsConstraintParameters, scene: Scene) {\r\n        if (!scene) {\r\n            throw new Error(\"Missing scene parameter for constraint constructor.\");\r\n        }\r\n        const physicsEngine = scene.getPhysicsEngine();\r\n        if (!physicsEngine) {\r\n            throw new Error(\"No Physics Engine available.\");\r\n        }\r\n        if (physicsEngine.getPluginVersion() != 2) {\r\n            throw new Error(\"Plugin version is incorrect. Expected version 2.\");\r\n        }\r\n        const physicsPlugin = physicsEngine.getPhysicsPlugin();\r\n        if (!physicsPlugin) {\r\n            throw new Error(\"No Physics Plugin available.\");\r\n        }\r\n\r\n        this._physicsPlugin = physicsPlugin as IPhysicsEnginePluginV2;\r\n        this._options = options;\r\n        this._type = type;\r\n    }\r\n\r\n    /**\r\n     * Gets the type of the constraint.\r\n     *\r\n     * @returns The type of the constraint.\r\n     *\r\n     */\r\n    public get type(): PhysicsConstraintType {\r\n        return this._type;\r\n    }\r\n\r\n    /**\r","sourceCodeStart":40,"sourceCodeEnd":76,"githubUrl":"https://github.com/BabylonJS/Babylon.js/blob/0592b347b8a4ee0236089ea86a749cacfdb266d8/packages/dev/core/src/Physics/v2/physicsConstraint.ts#L40-L76","documentation":"After validating the engine and its version, the constructor fetches the actual physics plugin via `physicsEngine.getPhysicsPlugin()`. If that returns null/undefined, the engine exists but has no usable plugin, so the constraint cannot be created.","triggerScenarios":"`scene.getPhysicsEngine()` exists but `getPhysicsPlugin()` returns falsy — e.g. `new PhysicsEngine(gravity, undefined)` was constructed manually, or the plugin was never supplied to enablePhysics/engine constructor.","commonSituations":"Manually instantiating a PhysicsEngine without a plugin argument; a custom/partial physics integration that registers an engine but no plugin; plugin creation failed earlier and the failure was swallowed.","solutions":["Pass a valid plugin instance to `scene.enablePhysics(gravity, plugin)` so getPhysicsPlugin() returns it","Check that plugin construction succeeded (e.g. Havok wasm initialized) before enabling physics","Log `scene.getPhysicsEngine()?.getPhysicsPlugin()` to confirm it is set before creating constraints"],"exampleFix":"// before\nscene.enablePhysics(gravity); // some paths create engine without plugin\nconst constraint = new PhysicsConstraint(type, options, scene); // throws\n// after\nconst havok = await HavokPhysics();\nscene.enablePhysics(gravity, new HavokPlugin(true, havok));\nconst constraint = new PhysicsConstraint(type, options, scene);","handlingStrategy":"validation","validationCode":"const engine = scene.getPhysicsEngine();\nif (!engine?.getPhysicsPlugin()) {\n  throw new Error('Physics engine has no plugin; pass a plugin to scene.enablePhysics');\n}","typeGuard":"function hasPhysicsPlugin(scene: BABYLON.Scene): boolean {\n  return !!scene.getPhysicsEngine()?.getPhysicsPlugin();\n}","tryCatchPattern":"try {\n  const shape = new PhysicsShape(options, scene);\n} catch (e) {\n  if (e.message.includes('No Physics Plugin')) {\n    // re-enable physics with an explicit plugin instance\n  }\n}","preventionTips":["Never call scene.enablePhysics without a plugin instance","Confirm Havok wasm initialization resolved before enabling physics","Assert getPhysicsPlugin() is set in bootstrap tests"],"tags":["physics","initialization","babylonjs"],"backgroundTag":"physics-engine-not-enabled","analyzedSha":"0592b347b8a4ee0236089ea86a749cacfdb266d8","analyzedAt":"2026-08-30T15:11:20.442Z","schemaVersion":2},"datasetVersion":"2026-08-30T18:17:15.746Z"}