YaPendulumComponent
YaPendulumComponent
controls an object in circular motion.
Functions
Events
Code samples
The following code sample demonstrates how to make an object start a circular motion.
| -- Prepares the component.
local pendulum = script:GetYaComponent("YaPendulumComponent")
-- Sets the center point to (0,0,1).
pendulum:SetCenterPoint(float3.New(0,0,1))
-- Sets the target angle to 1080 degrees.
pendulum:SetTargetAngle(1080)
-- Starts the circular motion.
pendulum:PlayMoving(true)
|
The following code samples demonstrate how an object sends an event which makes another object start a circular motion.
Sending an event.
| -- Prepares the component.
local _trigger = script:GetYaComponent("YaPhysicsMsg")
local function Trigger(t)
-- Executes the TriggerRotate event.
CustomEvents:Emit("TriggerRotate" , 1)
end
-- Adds the CharacterHit event.
EventHelper.AddListener(_trigger , "CharacterHit" ,Trigger )
|
Receiving the event.
| function Rotate(num)
if num == 1 then
-- Prepares the component.
local pendulum = script:GetYaComponent("YaPendulumComponent")
-- Starts the circular motion.
pendulum:PlayMoving(true)
end
end
-- Adds the custom event from ``TriggerRotate``.
EventHelper.AddListener(CustomEvents,"TriggerRotate" ,Rotate)
|