SetPosition

Sets the position of an entity in 3-dimensional space, using local or global coordinates.

Syntax

Parameters

Remarks

An entity can be positioned in local or global coordinates. Local coordinates are relative to the entity parent's space.

If the entity does not have a parent, local and global coordinates are the same.



Leadwerks uses a left-handed coordinate system.  This means that if you hold your left hand as shown below, your middle finger, index finger, and thumb will point in the directions of the X, Y, and Z axes, respectively.

Example

--Create a window
window = Window:Create()

context = Context:Create(window)

world = World:Create()

local camera = Camera:Create()
camera:SetRotation(35,0,0)
camera:Move(0,0,-6)

local light = DirectionalLight:Create()
light:SetRotation(35,35,0)

--Create a model
model = Model:Box()

while true do
        if window:Closed() or window:KeyHit(Key.Escape) then return end

        model:SetPosition(Math:Sin(Time:GetCurrent()/10.0),0,0)

        Time:Update()
        world:Update()
        world:Render()
        context:Sync()
end