Case Scenarios

Handling multiple actor tick subscriptions

local AAthenaPlayerCharacter = GetClass('Athena', 'AthenaPlayerCharacter')
local AShip = GetClass('Athena', 'Ship')
local ACannon = GetClass('Athena', 'Cannon')

function handleShip(cannon)
    -- do ship stuff here...
end

function onTickActor(actor)
    if actor:IsA(AShip) then
        handleShip(actor) -- we can handle it in another function
    elseif actor:IsA(AAthenaPlayerCharacter) then
        -- this is a player ...
    elseif actor:IsA(ACannon) then
        -- this is a cannon ...
    end
end

function onInitialize()
    SubscribeToTick(AAthenaPlayerCharacter)
    SubscribeToTick(AShip)
    SubscribeToTick(ACannon)
end

Last updated