Engine.DebugLua(true)

local ObjectTags = { "Red", "Green", "Blue" }
local Objects = {}
local OrbitRadius = 500
local OrbitSpeed = 1
local center = Vector2(1024, 1024) -- pivot point

local angles = {}



function OnInit()
    for i, tag in ipairs(ObjectTags) do
        local obj = Engine.GetObjectByTag(tag)
        if obj then
            Objects[i] = obj
            angles[i] = (i - 1) * (2 * math.pi / #ObjectTags)
        else
            Engine.LogError("Object '" .. tag .. "' not found!")
        end
    end
end

function OnUpdate(dt)
    for i, obj in ipairs(Objects) do
        if obj then
            angles[i] = angles[i] + OrbitSpeed * dt
            local angle = angles[i]
            local x = center.x + math.cos(angle) * OrbitRadius
            local y = center.y + math.sin(angle) * OrbitRadius
            obj:SetPosition(Vector2(x, y))
        end
    end
end
