Documentation

Unity Engine


User Manual

Script Reference

Unity Engine


DeltaAngle(float, float)

Calculates the shortest difference between two angles.
Read time 1 minuteLast updated 4 days ago

Definition

  • Type: Method
  • Namespace: UnityEngine
  • Assembly: UnityEngine.CoreModule
public static float DeltaAngle(float current, float target)

Parameters

current

The current angle in degrees.

target

The target angle in degrees.

Returns

Type

Description

floatA value between -180 (exclusive) and 180 (inclusive) in degrees

Examples

using UnityEngine;public class Example : MonoBehaviour{ void Start() { // Prints 90 Debug.Log(Mathf.DeltaAngle(1080, 90)); }}