Skip to content

Custom Scripts

Adrien Givry edited this page Apr 8, 2026 · 5 revisions

Creating a script

Every scripts in Overload are behaviours, meaning that when creating a script, your custom usertype will get interpreted by the engine as a behaviour that can be attached to any Actor.

In order to create a script, right-click on the Assets folder in the Asset Browser window, click "Create...", then "Script", enter a name, and press Enter.

Note

With older versions of Overload (1.8 and older), scripts have to go under the Scripts folder in the Asset Browser window!

Implementing your own behaviour

In order to create gameplay interactions in your scripts, you'll need to implement some of these functions:

Name Input Output Description
OnAwake Usertype: instance
Called when the scene start right before OnStart
OnStart Usertype: instance
Called when the scene start right after OnAwake
OnEnable Usertype: instance
Called when the behaviour gets enabled (owner SetActive set to true)
OnDisable Usertype: instance
Called when the behaviour gets disabled (owner SetActive set to false)
OnDestroy Usertype: instance
Called when the behaviour gets destroyed
OnUpdate Usertype: instance
number: deltaTime
Called every frame
OnFixedUpdate Usertype: instance
number: fixedDeltaTime
Called every physics frame
OnLateUpdate Usertype: instance
number: deltaTime
Called every frame after OnUpdate
OnCollisionEnter Usertype: instance
PhysicalObject: collideWith
Called when the owner of this behaviour enter in collision with another physical object
OnCollisionStay Usertype: instance
PhysicalObject: collideWith
Called when the owner of this behaviour is in collision with another physical object
OnCollisionExit Usertype: instance
PhysicalObject: collideWith
Called when the owner of this behaviour exit from collision with another physical object
OnTriggerEnter Usertype: instance
PhysicalObject: triggeredBy
Called when the owner of this behaviour enter in trigger with another physical object
OnTriggerStay Usertype: instance
PhysicalObject: triggeredBy
Called when the owner of this behaviour is in trigger with another physical object
OnTriggerExit Usertype: instance
PhysicalObject: triggeredBy
Called when the owner of this behaviour exit from trigger with another physical object

Example

---@class MoveUpDown : Behaviour
local MoveUpDown =
{
    elapsed = 0
}

-- Called when the scene starts
function MoveUpDown:OnStart()
end

-- Called every frame (The passed deltaTime holds the time elapsed between the current and previous frame in seconds)
function MoveUpDown:OnUpdate(deltaTime)
    -- Here, elapsed is incremented to sum the elapsed time since start
    self.elapsed = self.elapsed + deltaTime

    -- Stores the transform component instance into a variable
    transform = self.owner:GetTransform()

    -- Invoke SetPosition function with `:` to send the transform instance as first parameter to this function
    -- `transform:SetPosition(...)` is equivalent to `transform.SetPosition(transform, ...)`
    transform:SetPosition(Vector3.new(0, math.sin(self.elapsed), 0))

end

-- Returns the usertype so the engine has a reference to it
return MoveUpDown

Note

Ready to write some Lua code? Check out the scripting reference!

Clone this wiki locally