Skip to content

YaMoverComponent

YaMoverComponent determines whether an object moves and the way it moves.

Functions

void PlayMoving(bool play)
Determines whether the object moves. Set play to ture if you want to make the object move.
void SetMoveSpeed(number speed)
Sets the movement speed (m/s).
number GetMoveSpeed()
Gets the movement speed (m/s).
void SetTargetPosition(float3 targetPosition)
Sets the target position of the movement.
float3 GetTargetPosition()
Gets the target position of the movement.

Events

StartMoving
Triggered when the movement starts.
StopMoving
Triggered when the movement pauses.
FinishMoving
Triggered when the movement finishes.

Code sample

This following code sample makes the object move in the specified speed to the specified position.

1
2
3
4
5
6
7
8
--Prepares the component.
local mover = script:GetYaComponent("YaMoverComponent")
--Sets the movement speed to 5 m/s.
mover:SetMoveSpeed(5) 
-- Sets the target position of the movement to (0,100,0). 
mover:SetTargetPosition(float3.New(0,100,0)) 
-- Starts the movement.
mover:PlayMoving(true)