> A guide on best practices to achieve maximum performance with the Physics V2 API

Source: https://doc.babylonjs.com/features/featuresDeepDive/physics/perfTips

# Performance Tips

## ♻️ Reduce, Reuse, Recycle ♻️

The main point to take advantage of when using the API is to reuse as many objects as possible. For example, if you have a bowling game, instead of disposing of and recreating your ball and pins on every shot, you could keep the same objects and just reset their positions to the "default" state. By default, when you change the properties of the node associated with a body, there will be no effect. That is because the pre-step that updates the physics body with the values from the transform node is disabled by default to improve performance. You can solve this by enabling the pre-step for a frame and then disabling it again on the next frame:

```javascript
body.disablePreStep = false;
// The position where you want to move the body to
body.transformNode.position.set(1, 2, 3);
scene.onAfterRenderObservable.addOnce(() => {
    // Turn disablePreStep on again for maximum performance
    body.disablePreStep = true;
})
```

Please note that doing so may or may not allow the body to enter sleep mode, depending on the physics engine.

The reuse part also applies to collision shapes. Since bowling pins have the same shape, you can create only one PhysicsShape for all of them.

## Use simpler shapes

Whenever possible, don't use the entire mesh as a collision shape, especially when it's a very high poly mesh. Try to use [compounds](https://doc.babylonjs.com/features/featuresDeepDive/physics/compounds) or [convex hull shapes](https://doc.babylonjs.com/features/featuresDeepDive/physics/shapes) instead.

## Keep collision observables simple

[Collision observables](https://doc.babylonjs.com/features/featuresDeepDive/physics/collisionEvents) are functions that run every time a body collides with another. Since this can happen as often as every frame, it's important to avoid complex computations, or else the simulation will have to wait for these observables to finish before continuing.

- [Playground: Stress test](https://playground.babylonjs.com/#PX6E6C#25) - Instantiate many bodies to test the Physics engine performance

- [Playground: Convex Hull Vs Mesh Test](https://playground.babylonjs.com/#W3YL7Z#1) - Compare Convex hull and Mesh shapes
