Transform
Every GameObject has a Transform. Lua reads world position and Euler rotation,
and local scale. Rotations use degrees. Setters return false for a missing
GameObject, a non-finite number, or a value outside the PS1-safe range.
Position, Rotation, and Scale
Each vector property has a table getter, scalar axis getters, and a setter that accepts either a Vec3 or three numbers:
local position = Transform.GetPosition(gameObjectId)
local x = Transform.GetPositionX(gameObjectId)
Transform.SetPosition(gameObjectId, x + 1.0, position.y, position.z)
Transform.SetPosition(gameObjectId, { x = 0.0, y = 1.0, z = -2.0 })
local rotation = Transform.GetRotation(gameObjectId)
Transform.SetRotation(gameObjectId, rotation.x, 90.0, rotation.z)
local scale = Transform.GetScale(gameObjectId)
Transform.SetScale(gameObjectId, scale)
Methods:
Transform.GetPosition,Transform.GetPositionX,Transform.GetPositionY,Transform.GetPositionZ, andTransform.SetPosition;Transform.GetRotation,Transform.GetRotationX,Transform.GetRotationY,Transform.GetRotationZ, andTransform.SetRotation;Transform.GetScale,Transform.GetScaleX,Transform.GetScaleY,Transform.GetScaleZ, andTransform.SetScale.
Incremental Motion
Transform.RotateX, Transform.RotateY, and Transform.RotateZ add degrees to
the current Euler rotation. Transform.Translate adds a world-space offset.
rotationSpeed = 45.0
function Update(gameObjectId, deltaTime)
Transform.RotateY(gameObjectId, rotationSpeed * deltaTime)
Transform.Translate(gameObjectId, 0.0, 0.0, 0.25 * deltaTime)
end
Direct translation does not resolve locomotion collisions. Use
CharacterController.Move for a kinematic player or
NPC, and NavMeshAgent for movement along a baked path.