{"record":{"id":"616c82760f1b2b5f","repo":"BabylonJS/Babylon.js","slug":"no-physics-body-for-transformnode","errorCode":null,"errorMessage":"No Physics Body for TransformNode","messagePattern":"No Physics Body for TransformNode","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/dev/core/src/Physics/v2/physicsEngineComponent.pure.ts","lineNumber":64,"sourceCode":"\r\n    /**\r\n     * Gets the current physics body\r\n     * @returns a physics body or null\r\n     */\r\n    TransformNode.prototype.getPhysicsBody = function (): Nullable<PhysicsBody> {\r\n        return this.physicsBody;\r\n    };\r\n\r\n    /**\r\n     * Apply a physic impulse to the mesh\r\n     * @param force defines the force to apply\r\n     * @param contactPoint defines where to apply the force\r\n     * @returns the current mesh\r\n     * @see https://doc.babylonjs.com/features/featuresDeepDive/physics/usingPhysicsEngine\r\n     */\r\n    TransformNode.prototype.applyImpulse = function (force: Vector3, contactPoint: Vector3): TransformNode {\r\n        if (!this.physicsBody) {\r\n            throw new Error(\"No Physics Body for TransformNode\");\r\n        }\r\n        this.physicsBody.applyImpulse(force, contactPoint);\r\n        return this;\r\n    };\r\n\r\n    /**\r\n     * Apply a physic angular impulse to the mesh\r\n     * @param angularImpulse defines the torque to apply\r\n     * @returns the current mesh\r\n     * @see https://doc.babylonjs.com/features/featuresDeepDive/physics/usingPhysicsEngine\r\n     */\r\n    TransformNode.prototype.applyAngularImpulse = function (angularImpulse: Vector3): TransformNode {\r\n        if (!this.physicsBody) {\r\n            throw new Error(\"No Physics Body for TransformNode\");\r\n        }\r\n        this.physicsBody.applyAngularImpulse(angularImpulse);\r\n        return this;\r\n    };\r","sourceCodeStart":46,"sourceCodeEnd":82,"githubUrl":"https://github.com/BabylonJS/Babylon.js/blob/0592b347b8a4ee0236089ea86a749cacfdb266d8/packages/dev/core/src/Physics/v2/physicsEngineComponent.pure.ts#L46-L82","documentation":"The v2 physics component patches TransformNode.prototype.applyImpulse; it requires the node to have a `physicsBody` (created via `new PhysicsBody(node, ...)` or a PhysicsShape aggregation). Calling applyImpulse on a node without a body throws because there is nothing to apply the force to.","triggerScenarios":"Calling `transformNode.applyImpulse(force, contactPoint)` when `node.physicsBody` is undefined/null — body never created, already disposed, or created on a different node (e.g. the mesh instead of its TransformNode parent).","commonSituations":"Creating meshes without attaching a PhysicsBody while still calling impulse methods; disposing a body then continuing to simulate; using v1-style `mesh.physicsImpostor` code with the v2 API where the property is `physicsBody`.","solutions":["Create a body first: `node.physicsBody = new PhysicsBody(node, PhysicsMotionType.DYNAMIC, false, scene)`","Use `PhysicsShape` + `PhysicsBody` initialization helpers or character controllers that attach bodies automatically","Guard calls with `if (node.physicsBody)` before applying impulses","Confirm you are on the v2 API: bodies are `physicsBody`, not v1 `physicsImpostor`"],"exampleFix":"// before\nnode.applyImpulse(force, contactPoint); // throws: no body\n// after\nif (!node.physicsBody) {\n  node.physicsBody = new PhysicsBody(node, PhysicsMotionType.DYNAMIC, false, scene);\n}\nnode.applyImpulse(force, contactPoint);","handlingStrategy":"type-guard","validationCode":"if (!node.physicsBody) {\n  node.physicsBody = new BABYLON.PhysicsBody(node, BABYLON.PhysicsMotionType.DYNAMIC, false, scene);\n}\nnode.applyImpulse(force, contactPoint);","typeGuard":"function hasPhysicsBody(node: BABYLON.TransformNode): node is BABYLON.TransformNode & { physicsBody: BABYLON.PhysicsBody } {\n  return !!node.physicsBody;\n}","tryCatchPattern":"try {\n  node.applyImpulse(force, contactPoint);\n} catch (e) {\n  if (e.message.includes('No Physics Body')) {\n    node.physicsBody = new BABYLON.PhysicsBody(node, BABYLON.PhysicsMotionType.DYNAMIC, false, scene);\n    node.applyImpulse(force, contactPoint);\n  }\n}","preventionTips":["Create the PhysicsBody immediately after mesh/TransformNode creation","Do not dispose bodies while gameplay logic may still issue impulses","Remember v2 uses physicsBody, not the v1 physicsImpostor property"],"tags":["physics","undefined-body","babylonjs"],"backgroundTag":"missing-physics-body","analyzedSha":"0592b347b8a4ee0236089ea86a749cacfdb266d8","analyzedAt":"2026-08-30T15:11:20.442Z","schemaVersion":2},"datasetVersion":"2026-08-30T18:17:15.746Z"}