{"record":{"id":"980c492bffa75ffb","repo":"stride3d/stride","slug":"continuouscollisiondetection-must-be-enabled-at-physics","errorCode":null,"errorMessage":"ContinuousCollisionDetection must be enabled at physics engine initialization using the proper flag.","messagePattern":"ContinuousCollisionDetection must be enabled at physics engine initialization using the proper flag\\.","errorType":"exception","errorClass":"Exception","httpStatus":null,"severity":"error","filePath":"sources/engine/Stride.Physics/Simulation.cs","lineNumber":52,"sourceCode":"        private readonly BulletSharp.DispatcherInfo dispatchInfo;\n\n        private SimulationTickEvent preSimulationTick, postSimulationTick;\n\n        internal readonly bool CanCcd;\n\n        private float carriedDelta;\n\n#if DEBUG\n        private static readonly Logger Log = GlobalLogger.GetLogger(typeof(Simulation).FullName);\n#endif\n\n        public bool ContinuousCollisionDetection\n        {\n            get\n            {\n                if (!CanCcd)\n                {\n                    throw new Exception(\"ContinuousCollisionDetection must be enabled at physics engine initialization using the proper flag.\");\n                }\n\n                return dispatchInfo.UseContinuous;\n            }\n            set\n            {\n                if (!CanCcd)\n                {\n                    throw new Exception(\"ContinuousCollisionDetection must be enabled at physics engine initialization using the proper flag.\");\n                }\n\n                dispatchInfo.UseContinuous = value;\n            }\n        }\n\n        /// <summary>\n        /// Totally disable the simulation if set to true\n        /// </summary>","sourceCodeStart":34,"sourceCodeEnd":70,"githubUrl":"https://github.com/stride3d/stride/blob/96fad776d210c221682aac1ccdf4c79dc046fc38/sources/engine/Stride.Physics/Simulation.cs#L34-L70","documentation":"The ContinuousCollisionDetection getter on Stride's Simulation only works if the underlying physics engine (Bullet) was initialized with the CCD flag. If CanCcd is false (PhysicsEngineFlags.ContinuousCollisionDetection not set in the configuration), reading the property throws because the feature is unavailable in this simulation instance.","triggerScenarios":"Reading the Simulation.ContinuousCollisionDetection property when the Simulation was created with a PhysicsConfiguration whose Flags do not include PhysicsEngineFlags.ContinuousCollisionDetection.","commonSituations":"Enabling CCD in a game component or script at runtime without having set the flag at engine initialization; default project templates that don't pass the CCD flag to the physics engine.","solutions":["Set PhysicsEngineFlags.ContinuousCollisionDetection in the PhysicsConfiguration flags BEFORE the physics engine/Simulation is created","Check CanCcd before accessing the property and skip CCD configuration if unavailable","Reconfigure the physics engine initialization code (e.g. in the scene's physics settings or Simulation creation) and restart the application"],"exampleFix":"// before\nvar simulation = this.GetSimulation();\nsimulation.ContinuousCollisionDetection = true; // throws if flag unset\n// after\nvar config = new PhysicsConfiguration { Flags = PhysicsEngineFlags.ContinuousCollisionDetection };\nvar simulation = new Simulation(this, config);\nsimulation.ContinuousCollisionDetection = true;","handlingStrategy":"validation","validationCode":"if (simulation.CanCcd)\n{\n    var ccd = simulation.ContinuousCollisionDetection;\n}\nelse\n{\n    // CCD not enabled at initialization\n}","typeGuard":null,"tryCatchPattern":"try\n{\n    var ccd = simulation.ContinuousCollisionDetection;\n}\ncatch (Exception ex) when (ex.Message.Contains(\"ContinuousCollisionDetection\"))\n{\n    // fall back: CCD unavailable, use smaller timestep\n}","preventionTips":["Set PhysicsEngineFlags.ContinuousCollisionDetection in PhysicsConfiguration flags at engine initialization if you plan to use CCD","Check CanCcd before touching any CCD-related API","Centralize physics configuration in one place so required flags are documented and consistently applied"],"tags":["physics","ccd","initialization","feature-flag"],"backgroundTag":"feature-not-enabled","analyzedSha":"96fad776d210c221682aac1ccdf4c79dc046fc38","analyzedAt":"2026-09-14T02:59:31.279Z","contentChangedAt":"2026-09-14T02:59:31.279Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}