On Trigger Object

API -

function yourEvent(user, object, eventType)
    if user ~= nil then
        if eventType == 'enter' then
            log(user.displayName .. 'entered');
        end
        if eventType == 'exit' then
            log(user.displayName .. 'exited');
        end
    else
        if eventType == 'mouseEntered' then
        end
        if eventType == 'mouseExited' then
        end
        if eventType == 'mouseDown_0' then
        end
        if eventType == 'mouseUp_0' then
        end
     end
end

return function()
    local app = getApp();
    local myObject = app.createGameObject();
    wait(3);
    myObject.physics.addBoxTrigger();
    myObject.physics.mouseTrigger = true; --enables mouse tracking on object
    log(myObject.physics.hasTrigger);
    
    app.addEvent('triggerObject', 'yourEvent');
    --as soon as the script ends the object will be destroyed automatically.
    keepAlive();
end

Events are asynchronous coroutines.

Last updated