Version: Unity 6.5 Alpha (6000.5)
Language : English
Introduction to Unity math APIs
Common math functions with the Mathf class

Unity Engine math APIs

The UnityEngine includes math APIs best-suited for use in projects that are just-in-time (JIT) compiled with the Mono scripting backend. This includes the Mathf class for common math functions, including trignomometric, logarithmic, and other oprations. It also includes classes for data structures such as Vector2, Vector3, Matrix4x4, Quaternion, and UnityEngine.Random.

The UnityEngine 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.

Topic Description
Common math functions with the Mathf class Use Unity’s Mathf class to apply trigonometric, logarithmic, and other math functions commonly required in game development.
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 Random class to generate various types of random values commonly required in game development.
Controlling rotation with the Quaternion class Use euler angles or quaternionsUnity’s standard way of representing rotations as data. When writing code that deals with rotations, you should usually use the Quaternion class and its methods. More info
See in Glossary
in Unity’s left hand coordinate system to control the rotation and orientation of GameObjectsThe fundamental object in Unity scenes, which can represent characters, props, scenery, cameras, waypoints, and more. A GameObject’s functionality is defined by the Components attached to it. More info
See in Glossary
.

Additional resources

Introduction to Unity math APIs
Common math functions with the Mathf class