BabylonJS/Babylon.js · critical
No Physics Engine available.
Error message
No Physics Engine available.
What it means
PhysicsBody's constructor pulls the physics engine from scene.getPhysicsEngine(). If the scene has no engine (enablePhysics was never called or returned false), the body cannot register with anything and the constructor throws immediately. It is a guard against silently creating a body that would never simulate.
Source
Thrown at packages/dev/core/src/Physics/v2/physicsBody.ts:108
* @param transformNode - The Transform Node to construct the physics body for. For better performance, it is advised that this node does not have a parent.
* @param motionType - The motion type of the physics body. The options are:
* - PhysicsMotionType.STATIC - Static bodies are not moving and unaffected by forces or collisions. They are good for level boundaries or terrain.
* - PhysicsMotionType.DYNAMIC - Dynamic bodies are fully simulated. They can move and collide with other objects.
* - PhysicsMotionType.ANIMATED - They behave like dynamic bodies, but they won't be affected by other bodies, but still push other bodies out of the way.
* @param startsAsleep - Whether the physics body should start in a sleeping state (not a guarantee). Defaults to false.
* @param scene - The scene containing the physics engine.
*
* This code is useful for creating a physics body for a given Transform Node in a scene.
* It checks the version of the physics engine and the physics plugin, and initializes the body accordingly.
* It also sets the node's rotation quaternion if it is not already set. Finally, it adds the body to the physics engine.
*/
constructor(transformNode: TransformNode, motionType: PhysicsMotionType, startsAsleep: boolean, scene: Scene) {
if (!scene) {
return;
}
const physicsEngine = scene.getPhysicsEngine() as PhysicsEngine;
if (!physicsEngine) {
throw new Error("No Physics Engine available.");
}
this._physicsEngine = physicsEngine;
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;
if (!transformNode.rotationQuaternion) {
transformNode.rotationQuaternion = Quaternion.FromEulerAngles(transformNode.rotation.x, transformNode.rotation.y, transformNode.rotation.z);
}
this.startAsleep = startsAsleep;
// only dynamic and animated body needs sync from physics to transformNode
View on GitHub (pinned to 0592b347b8)
Solutions
- Initialize physics first: const havok = await HavokPlugin(); scene.enablePhysics(new Vector3(0,-9.81,0), havok); before creating any PhysicsBody.
- Check scene.getPhysicsEngine() is truthy before constructing bodies; guard creation behind that check.
- Confirm you enabled physics on the same Scene object the bodies are created in.
Example fix
// before
const body = new PhysicsBody(box, PhysicsMotionType.DYNAMIC, false, scene);
// after
const havok = await HavokPlugin();
if (!scene.enablePhysics(new Vector3(0, -9.81, 0), havok)) throw new Error("physics failed to init");
const body = new PhysicsBody(box, PhysicsMotionType.DYNAMIC, false, scene); Defensive patterns
Strategy: validation
Validate before calling
if (!scene.getPhysicsEngine()) {
throw new Error("enable physics before creating bodies: await HavokPlugin(); scene.enablePhysics(gravity, havok)");
}
const body = new PhysicsBody(mesh, PhysicsMotionType.DYNAMIC, false, scene); Type guard
function hasPhysicsEngine(scene: Scene): scene is Scene & { getPhysicsEngine(): PhysicsEngine } {
return !!scene.getPhysicsEngine();
} Try / catch
try {
const body = new PhysicsBody(mesh, PhysicsMotionType.DYNAMIC, false, scene);
} catch (e) {
if ((e as Error).message.includes("No Physics Engine available")) {
const havok = await HavokPlugin();
scene.enablePhysics(new Vector3(0, -9.81, 0), havok);
// retry body creation here
} else { throw e; }
} Prevention
- Initialize physics (await HavokPlugin + scene.enablePhysics) at app startup, before any body creation.
- Use the exact Scene instance physics was enabled on for all bodies.
- Assert scene.getPhysicsEngine() exists in your physics setup helper.
When it happens
Trigger: new PhysicsBody(mesh, PhysicsMotionType.DYNAMIC, false, scene) on a scene where scene.getPhysicsEngine() returns null — HavokPlugin not enabled, or the scene is not the one physics was enabled on.
Common situations: Forgetting await HavokPlugin() / scene.enablePhysics before creating bodies; enabling physics on a different Scene instance than the one used to build bodies; enablePhysics silently failing because the plugin failed to initialize.
Related errors
- No Physics Plugin available.
- Plugin version is incorrect. Expected version 2.
- Missing scene parameter for constraint constructor.
- No Physics Engine available.
- No Physics Plugin available.
AI-assisted analysis of BabylonJS/Babylon.js@0592b347b8 (2026-08-30).
Data as JSON: /api/errors/f48bc32100eb428f.
Report an issue: GitHub.