This script translates all objects in the world to keep the camera near the origin in order to prevent spatial jittering due to limited floating-point precision.
The script detects when the camera is further than ‘threshold’ units from the origin in one or more axes, at which point it moves everything so that the camera is back at the origin. There is also an option to disable physics beyond a certain point. This script should normally be attached to the viewpoint, typically the main camera.
Related: Shifting Origin
Properties¶
Threshold |
Use a power of 2 to avoid pops in water surface geometry. |
Physics Threshold |
The threshold to apply the sleep threshold. Set to zero to disable. |
Physics Sleep Threshold |
The mass-normalized energy threshold, below which objects start going to sleep. |
Override Transform List |
Optionally provide a list of transforms to avoid doing a FindObjectsByType call. |
Override Particle System List |
Optionally provide a list of particle systems to avoid doing a FindObjectsByType call. |
Override Rigid Body List |
Optionally provide a list of rigid bodies to avoid doing a FindObjectsByType call. |
Integration Mode |
Whether to operate in Integration Mode. If enabled, it will no longer shift the origin for everything automatically. To shift the water origin, call ShiftWaterOrigin. This is useful if you are handling origin shift for other objects yourself. |