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

Function

moveObject

Smoothly moves an object to a new place over the given time, optionally rotating it by the given angles (relative to its current rotation) and with the chosen easing. Everyone sees the movement; when it ends the object stays in the new place. Used for gates, lifts, platforms. Easing: "Linear", "InQuad", "OutQuad", "InOutQuad", "OutInQuad", "SineCurve", "CosineCurve".

Syntax

bool moveObject(object theObject, int time, float targetx, float targety, float targetz [, float moverx = 0, float movery = 0, float moverz = 0, string strEasingType = "Linear"])

Arguments

theObjectobject
The object.
timeint
Movement time in ms (at least 50).
targetxfloat
Target X.
targetyfloat
Target Y.
targetzfloat
Target Z.
moverxfloat, optional = 0
Rotate by this many degrees around X.
moveryfloat, optional = 0
Rotation around Y.
moverzfloat, optional = 0
Rotation around Z.
strEasingTypestring, optional = "Linear"
Easing type.

Differences from MTA:SA

  • These MTA:SA arguments are not here: float fEasingPeriod, float fEasingAmplitude, float fEasingOvershoot

In MTA:SA

moveObject(object theObject, int time, float targetx, float targety, float targetz, float moverx, float movery, float moverz, string strEasingType, float fEasingPeriod, float fEasingAmplitude, float fEasingOvershoot)

Returns

true on success.

Example

local gate = createObject(980, 2500, -1700, 15)
local open = false
addCommandHandler("brama", function()
    open = not open
    moveObject(gate, 3000, 2500, -1700, open and 9 or 15, 0, 0, 0, "InOutQuad")
end)

See also