{"record":{"id":"2cec00c0c72140b9","repo":"BabylonJS/Babylon.js","slug":"unknown-motion-type-type","errorCode":null,"errorMessage":"Unknown motion type: ${type}","messagePattern":"Unknown motion type: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/dev/core/src/Physics/v2/Plugins/havokPlugin.ts","lineNumber":1278,"sourceCode":"\r\n    /**\r\n     * Gets the motion type of a physics body.\r\n     * @param body - The physics body to get the motion type from.\r\n     * @param instanceIndex - The index of the instance to get the motion type from. If not specified, the motion type of the first instance will be returned.\r\n     * @returns The motion type of the physics body.\r\n     */\r\n    public getMotionType(body: PhysicsBody, instanceIndex?: number): PhysicsMotionType {\r\n        const pluginRef = this._getPluginReference(body, instanceIndex);\r\n        const type = this._hknp.HP_Body_GetMotionType(pluginRef.hpBodyId)[1];\r\n        switch (type) {\r\n            case this._hknp.MotionType.STATIC:\r\n                return PhysicsMotionType.STATIC;\r\n            case this._hknp.MotionType.KINEMATIC:\r\n                return PhysicsMotionType.ANIMATED;\r\n            case this._hknp.MotionType.DYNAMIC:\r\n                return PhysicsMotionType.DYNAMIC;\r\n        }\r\n        throw new Error(\"Unknown motion type: \" + type);\r\n    }\r\n\r\n    /**\r\n     * sets the activation control mode of a physics body, for instance if you need the body to never sleep.\r\n     * @param body - The physics body to set the activation control mode.\r\n     * @param controlMode - The activation control mode.\r\n     */\r\n    public setActivationControl(body: PhysicsBody, controlMode: PhysicsActivationControl): void {\r\n        switch (controlMode) {\r\n            case PhysicsActivationControl.ALWAYS_ACTIVE:\r\n                this._hknp.HP_Body_SetActivationControl(body._pluginData.hpBodyId, this._hknp.ActivationControl.ALWAYS_ACTIVE);\r\n                break;\r\n            case PhysicsActivationControl.ALWAYS_INACTIVE:\r\n                this._hknp.HP_Body_SetActivationControl(body._pluginData.hpBodyId, this._hknp.ActivationControl.ALWAYS_INACTIVE);\r\n                break;\r\n            case PhysicsActivationControl.SIMULATION_CONTROLLED:\r\n                this._hknp.HP_Body_SetActivationControl(body._pluginData.hpBodyId, this._hknp.ActivationControl.SIMULATION_CONTROLLED);\r\n                break;\r","sourceCodeStart":1260,"sourceCodeEnd":1296,"githubUrl":"https://github.com/BabylonJS/Babylon.js/blob/0592b347b8a4ee0236089ea86a749cacfdb266d8/packages/dev/core/src/Physics/v2/Plugins/havokPlugin.ts#L1260-L1296","documentation":"HavokPlugin translates Babylon PhysicsMotionType values to Havok MotionType constants via a switch. If the incoming value matches none of STATIC/ANIMATED/DYNAMIC cases, the mapping has no Havok equivalent and the plugin throws rather than guessing. This indicates the caller passed an invalid or unmapped motion type.","triggerScenarios":"Passing an invalid/undefined value (or a stale import of PhysicsMotionType from a mismatched Babylon build) to body construction or physicsBody.setMotionType(), so the internal conversion switch falls through to the throw at havokPlugin.ts:1278.","commonSituations":"Constructing a PhysicsBody with a hand-written numeric motion type; mixing @babylonjs/core and @babylonjs/havok versions so enum values differ; typos like PhysicsMotionType.KINEMATIC (the Babylon name is ANIMATED).","solutions":["Only pass values from the imported PhysicsMotionType enum (STATIC, ANIMATED, DYNAMIC); never raw numbers or strings.","Verify @babylonjs/core and @babylonjs/havok are at compatible versions in package.json and reinstall so a single shared enum module is used.","Log the value before creating the body to confirm it is one of the three valid enum members."],"exampleFix":"// before\nconst body = new PhysicsBody(mesh, 4 as any, false, scene);\n// after\nconst body = new PhysicsBody(mesh, PhysicsMotionType.DYNAMIC, false, scene);","handlingStrategy":"validation","validationCode":"const VALID = [PhysicsMotionType.STATIC, PhysicsMotionType.ANIMATED, PhysicsMotionType.DYNAMIC];\nif (!VALID.includes(motionType)) {\n  throw new Error(`motionType must be a PhysicsMotionType enum member, got: ${motionType}`);\n}","typeGuard":"function isValidMotionType(t: unknown): t is PhysicsMotionType {\n  return t === PhysicsMotionType.STATIC || t === PhysicsMotionType.ANIMATED || t === PhysicsMotionType.DYNAMIC;\n}","tryCatchPattern":null,"preventionTips":["Always use the PhysicsMotionType enum members, never raw numbers or strings.","Pin @babylonjs/core and @babylonjs/havok to compatible versions and install them together.","Remember Babylon's names: STATIC, ANIMATED (kinematic), DYNAMIC."],"tags":["physics","havok","enum","invalid-argument"],"backgroundTag":"unknown-motion-type","analyzedSha":"0592b347b8a4ee0236089ea86a749cacfdb266d8","analyzedAt":"2026-08-30T15:11:20.442Z","schemaVersion":2},"datasetVersion":"2026-08-30T18:17:15.746Z"}