Skip to content

YaMoverComponent

YaMoverComponent determines whether an object moves and the way it moves. YaMoverComponent can only function when the Mover module (https://developer.yahaha.com/manual/yahaha-studio-manual/scripting/module/module-reference/Mover/) is added to the same object.

Functions

void Start()

SERVER ONLY 
Starts the object moves

void Stop()

SERVER ONLY 
Stops the object moves

void SetSpeed(number speed)

SERVER ONLY 
Sets the movement speed (m/s).
  • speed speed(m/s)

number GetSpeed()

SERVER ONLY 
Gets the movement speed (m/s).

void SetTargetPosition(float3 position)

SERVER ONLY 
Sets the target position of the movement.
  • position global position.

float3 GetTargetPosition()

SERVER ONLY 
Gets the target position of the movement.

Events

StartEvent<void>

SERVER ONLY 
Triggered when the movement starts.

PauseEvent<void>

SERVER ONLY 
Triggered when the movement pauses.

FinishEvent<void>

SERVER ONLY 
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:SetSpeed(5)
-- Sets the target position of the movement to (0,100,0).
mover:SetTargetPosition(float3.New(0,100,0))
-- Starts the movement.
mover:Start()