-- ============================================================================ -- 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