int SubSteps { get; set; }

book_4_sparkGenerated
code_blocksInput

Description

The SubSteps property of the PhysicsWorld class allows you to control the number of substeps that the physics engine performs per tick. This can be useful if you are experiencing issues with objects passing through each other or if you have a low tickrate. By increasing the number of substeps, you can achieve more accurate physics simulations at the cost of increased computational load.

The default value for SubSteps is 1, which generally provides a good balance between performance and accuracy. However, if you find that your physics simulation is not behaving as expected, you may consider increasing this value.

It is important to note that the total number of physics ticks per second is calculated as tickrate * SubSteps. For example, if your tickrate is 90 and you set SubSteps to 1000, the engine will perform 90,000 physics steps per second, which can significantly impact performance. Therefore, it is crucial to adjust this value carefully based on your specific needs and performance constraints.

Usage

To adjust the SubSteps property, you can simply set it to the desired integer value. This should be done with consideration of the performance implications, as higher values will increase the computational load on the physics engine.

Example usage:

PhysicsWorld physicsWorld = new PhysicsWorld();
physicsWorld.SubSteps = 10; // Increase substeps for more accurate simulation

In this example, the SubSteps property is set to 10, which means the physics engine will perform 10 substeps per tick, potentially improving the accuracy of the simulation.

Example

PhysicsWorld physicsWorld = new PhysicsWorld();
physicsWorld.SubSteps = 10; // Increase substeps for more accurate simulation