ServersYour serverFor creatorsForumFAQDocumentationSecurity
Download the launcher
  1. Documentation
  2. Shared functions
  3. interpolateAngle

Function

interpolateAngle

Server and clientMath, vectors and matricesTrilogy Hub only

Computes an angle between two angles, going the shorter way. The result is in the 0-360 range.

Syntax

float interpolateAngle(float from, float to, float progress)

Arguments

fromfloat
The start angle.
tofloat
The target angle.
progressfloat
Progress from 0 to 1.

Returns

The interpolated angle.

Example

Smoothly turning an object towards a target.

local obj = createObject(1337, 0, 0, 3)
local target = 270
setTimer(function()
    local _, _, rz = getElementRotation(obj)
    setElementRotation(obj, 0, 0, interpolateAngle(rz, target, 0.2))
end, 50, 0)

See also