Unity Engine math APIs
Use the collection of math APIs in the Unity.Engine namespace to access common mathematical operations.
Read time 1 minuteLast updated 6 days ago
The includes math APIs best-suited for use in projects that are just-in-time (JIT) compiled with the Mono scripting backend. This includes the class for common math functions, including trignomometric, logarithmic, and other oprations. It also includes classes for data structures such as , , , , and .
UnityEngineMathfVector2Vector3Matrix4x4QuaternionUnityEngine.RandomThe math APIs are recommended for code that is not Burst compiled. In Burst compiled code, use the Unity.Mathematics APIs instead, which are optimized for Burst compilation.
UnityEngineTopic | Description |
|---|---|
| Common math functions with the Mathf class | Use Unity's |
| Moving objects with the Vector classes | Perform vector arithmetic with Unity's 2D, 3D, and 4D vector classes to manage the position and speed of objects and the distance between them. |
| Generating random numbers with the Random class | Use the |
| Controlling rotation with the Quaternion class | Use euler angles or quaternions in Unity's left hand coordinate system to control the rotation and orientation of GameObjects. |