Skip to content

YaMovableComponent

YaMovableComponent determines the position, rotation, and scale of an object in games.

Functions

void SetPosition(float3 position)
Sets the local position of the object. Local position is the position of the object relative to the parent object.
float3 GetPosition()
Gets the local position of the object.
float3 GetGlobalPosition()
Gets the world position of the object. World position is the position of the object in the space.
void SetRotation(float3 rotation)
Sets the local rotation of the object. Local rotation is the rotation of the object relative to the rotation of the parent object.
float3 GetRotation()
Gets the local rotation of the object.
float3 GetGlobalRotation()
Gets the world rotation of the object. World rotation is the rotation of the object in the space.

Code sample

This following code sample sets the specified position and rotation for the object.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
--Prepares the component.
local cmp = script:GetYaComponent("YaMovableComponent")
--Gets the object position.
local position = cmp:GetPosition() 
--Updates the object position.
position.x = position.x + 20
position.y = 10
cmp:SetPosition(position)
--Gets the object position.
local rotation = cmp:GetRotation() 
--Updates the object rotation.
rotation.x = rotation.x + 90
cmp:SetRotation(rotation)