Skip to content

YaSpinnerComponent

YaSpinnerComponent determines whether an object spin and the way it spins.

Functions

void PlayMoving(bool play)
Deterimines whether the object starts to spin. Set play to ture if you want to make the object spin.
void SetRotateSpeed(speed)
Sets the spin speed (m/s).
number GetRotateSpeed()
Gets the spin speed (m/s).
void SetTargetAngle(number angle)
Sets the target angle of the spin. The spin won't stop when the target is reached and the event `FinishRotate` is triggered.
number GetTargetAngle()
Returns the target angel.

Events

StartRotate
Triggered when the spin starts.
StopRotate
Triggered when the spin pauses.
FinishRotate
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 radius/s.
spinner:SetRotateSpeed(5) 
-- Sets the target angel to 360 degrees.
spinner:SetTargetAngle(360) 
-- Starts spinning.
spinner:PlayMoving(true)