Skip to content

YaSpinnerComponent

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

Functions

void Start()

SERVER ONLY 
Starts the object spin.

void Stop()

SERVER ONLY 
Stops the object spin.

void SetRotationAxis(float3 axis)

SERVER ONLY 
Sets the target rotation axis.
  • axis axis

float3 GetRotationAxis()

SERVER ONLY 
Gets the target rotation axis.

number GetSpeed()

SERVER ONLY 
Gets the spin speed.

void SetSpeed(number speed)

SERVER ONLY 
Sets the spin speed.

void SetTargetAngle(number angle)

SERVER ONLY 
Sets the target angle of the spin. The spin won't stop when the target is reached and the event FinishEvent is triggered.
  • angle angle of rotation

number GetTargetAngle()

SERVER ONLY 
Returns the target angle.

Events

StartEvent<void>

SERVER ONLY 
Triggered when the spin starts.

PauseEvent<void>

SERVER ONLY 
Triggered when the spin pauses.

FinishEvent<void>

SERVER ONLY 
Triggered when the spin finishes.

Code sample

This following code sample makes the object spin in the specified speed, around the specified axis, to the specified angle.

1
2
3
4
5
6
7
8
-- Prepares the component.
local spinner = script:GetYaComponent("YaSpinnerComponent")
-- Sets the speed to 5.
spinner:SetSpeed(5)
-- Sets the target angel to 360 degrees.
spinner:SetTargetAngle(360)
-- Starts spinning.
spinner:Start()