lul
This commit is contained in:
25
Assets/lua/spinner.lua
Normal file
25
Assets/lua/spinner.lua
Normal file
@@ -0,0 +1,25 @@
|
||||
-- ============================================================================
|
||||
-- spinner.lua - Continuously rotating object (onUpdate demo)
|
||||
-- ============================================================================
|
||||
-- Tests: onUpdate, self.rotationY, Entity.GetRotationY, Entity.SetRotationY,
|
||||
-- Timer.GetFrameCount, self.position, Entity.GetPosition
|
||||
|
||||
local speed = 1 -- pi-units per frame
|
||||
|
||||
function onCreate(self)
|
||||
Debug.Log("Spinner created, initial rotY: " .. self.rotationY)
|
||||
end
|
||||
|
||||
function onUpdate(self, dt)
|
||||
-- Rotate the object by speed * dt each frame
|
||||
local current = Entity.GetRotationY(self)
|
||||
Entity.SetRotationY(self, current + speed * dt)
|
||||
|
||||
-- Every 300 frames, log position and rotation (test Timer)
|
||||
if Timer.GetFrameCount() % 300 == 0 then
|
||||
local pos = Entity.GetPosition(self)
|
||||
Debug.Log("Spinner at frame " .. Timer.GetFrameCount()
|
||||
.. " pos=" .. pos.x .. "," .. pos.y .. "," .. pos.z
|
||||
.. " rotY=" .. Entity.GetRotationY(self))
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user