Run 2D physics in 3D space with 2D Physics Core
Create a 2D physics world at any angle in 3D space, instead of the traditional x, y plane that faces the camera.
Read time 1 minuteLast updated 13 days ago
Create a 2D physics world at any angle in 3D space, instead of the traditional x, y plane that faces the camera. This allows you to use 2D physics in a 3D game.
To run 2D physics in 3D space, follow these steps:
- Create a physics world.
- In the window of the Physics Simulation Definition asset, set Transform Plane to XZ, ZY, or Custom.Inspector
?
The options are:
- XY means the x-axis remains horizontal and the y-axis remains vertical, so that the world faces the camera in 3D space. This is the default.
- XZ means the x-axis remains horizontal but the y-axis becomes depth, so that the world lies flat in 3D space.
- ZY means the x-axis becomes depth but the y-axis remains vertical, so that the world stands upright in 3D space.
- Custom means Unity uses the plane you define.
The physics system continues to use 2D coordinates and vectors, but Unity converts the final positions to 3D space.
Vector2To convert coordinates manually between 2D and 3D types, use the helper methods in the API.
Vector2Vector3PhysicsMath