BabylonJS/Babylon.js · error
No Physics Engine available.
Error message
No Physics Engine available.
What it means
The PhysicsShape (v2) constructor requires the scene to have a physics engine. Unlike the constraint constructor it silently returns if scene is missing, but if the scene exists without an engine (`scene.getPhysicsEngine()` falsy), it throws because shapes need the plugin to create plugin-side data.
Source
Thrown at packages/dev/core/src/Physics/v2/physicsShape.ts:72
* Constructs a new physics shape.
* @param options The options for the physics shape. These are:
* * type: The type of the shape. This can be one of the following: SPHERE, BOX, CAPSULE, CYLINDER, CONVEX_HULL, MESH, HEIGHTFIELD, CONTAINER
* * parameters: The parameters of the shape.
* * pluginData: The plugin data of the shape. This is used if you already have a reference to the object on the plugin side.
* You need to specify either type or pluginData.
* @param scene The scene the shape belongs to.
*
* This code is useful for creating a new physics shape with the given type, options, and scene.
* It also checks that the physics engine and plugin version are correct.
* If not, it throws an error. This ensures that the shape is created with the correct parameters and is compatible with the physics engine.
*/
constructor(options: PhysicShapeOptions, scene: Scene) {
if (!scene) {
return;
}
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;
if (options.pluginData !== undefined && options.pluginData !== null) {
this._pluginData = options.pluginData;
this._type = this._physicsPlugin.getShapeType(this);
} else if (options.type !== undefined && options.type !== null) {
this._type = options.type;
const parameters = options.parameters ?? {};
this._physicsPlugin.initShape(this, options.type, parameters);
}
View on GitHub (pinned to 0592b347b8)
Solutions
- Call `scene.enablePhysics(new Vector3(0,-9.81,0), new HavokPlugin())` before creating shapes
- Ensure the same scene instance is passed to both enablePhysics and the PhysicsShape constructor
- Await Havok wasm initialization before any physics object construction
Example fix
// before
const shape = new PhysicsShape({ type: PhysicsShapeType.BOX }, scene); // throws
// after
await HavokPhysics().then(havok => scene.enablePhysics(new Vector3(0,-9.81,0), new HavokPlugin(true, havok)));
const shape = new PhysicsShape({ type: PhysicsShapeType.BOX }, scene); Defensive patterns
Strategy: validation
Validate before calling
if (!scene.getPhysicsEngine()) {
throw new Error('Physics must be enabled before creating a PhysicsShape');
}
const shape = new PhysicsShape(options, scene); Type guard
function canCreatePhysicsShape(scene: BABYLON.Scene): boolean {
return !!scene.getPhysicsEngine();
} Try / catch
try {
const shape = new PhysicsShape(options, scene);
} catch (e) {
if (e.message.includes('No Physics Engine')) {
// enable physics with a v2 plugin, then retry
}
} Prevention
- Enable physics before any shape/body/constraint construction
- Keep one canonical scene for physics; avoid passing overlay scenes
- Structure boot as: await Havok -> enablePhysics -> build objects
When it happens
Trigger: `new PhysicsShape(options, scene)` where physics was never enabled on that scene — `scene.enablePhysics(gravity, v2Plugin)` not called, called on another scene, or disabled before shape creation.
Common situations: Creating shapes before async Havok initialization completes; passing the wrong scene (e.g. a UI/overlay scene); tests creating shapes on bare scenes.
Related errors
- No Physics Engine available.
- No Physics Plugin available.
- No Physics Plugin available.
- No Physics Engine available.
- No Physics Plugin available.
AI-assisted analysis of BabylonJS/Babylon.js@0592b347b8 (2026-08-30).
Data as JSON: /api/errors/f64cdfec23b75719.
Report an issue: GitHub.