SetEntityRotation
Turns a prop about all three axes - stands up a mesh that lies on its side, tilts a piece.
Some of the game’s meshes lie on their side (shelves, racks, some wall pieces); a pitch or a roll of 90 stands them up. yaw
is the turn about the vertical, as CreateProp’s (nil keeps the prop’s own); pitch tips the prop’s front up, about its
own right-hand axis; roll leans its top to its right, about its own forward axis - all in degrees, nil reads as 0. The game
turns it by the yaw first, then the roll, then the pitch. Everyone who sees the prop follows at once, and a prop turned right
after CreateProp appears turned. Its collision turns with it. Nothing is kept past the prop: a mode that saves its furniture
stores the three angles (GetEntityRotation) and turns each piece again when it makes it.
Syntax
Section titled “Syntax”SetEntityRotation(id, yaw [, pitch, roll])| Parameter | Type | |
|---|---|---|
id |
number | the prop |
yaw |
number | nil | degrees about the vertical; nil = the prop’s own |
pitch |
number | degrees, its front up (0) (optional) |
roll |
number | degrees, its top to its right (0) (optional) |
Returns
Section titled “Returns”boolean - false for anything that is not a prop
Example
Section titled “Example”-- a shelf that lies on its back in the game's files, stood up against a walllocal shelf = CreateProp(mesh, x, y, z, yaw)SetEntityRotation(shelf, yaw, 90, 0)
-- a player tilts the piece they are placing with the arrow keys (a client script sends "tilt" with -1 / 1)function OnClientEvent(pid, name, step) if name == "tilt" and placing[pid] then local yaw, pitch, roll = GetEntityRotation(placing[pid]) SetEntityRotation(placing[pid], yaw, pitch + 15 * tonumber(step), roll) endendSee also
Section titled “See also”GetEntityRotation · CreateProp · SetEntityPos · the Props group of the index
