-
Notifications
You must be signed in to change notification settings - Fork 283
Custom Scripts
Adrien Givry edited this page Apr 8, 2026
·
5 revisions
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!
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: instancenumber: deltaTime |
Called every frame | |
| OnFixedUpdate |
Usertype: instancenumber: fixedDeltaTime |
Called every physics frame | |
| OnLateUpdate |
Usertype: instancenumber: deltaTime |
Called every frame after OnUpdate | |
| OnCollisionEnter |
Usertype: instancePhysicalObject: collideWith |
Called when the owner of this behaviour enter in collision with another physical object | |
| OnCollisionStay |
Usertype: instancePhysicalObject: collideWith |
Called when the owner of this behaviour is in collision with another physical object | |
| OnCollisionExit |
Usertype: instancePhysicalObject: collideWith |
Called when the owner of this behaviour exit from collision with another physical object | |
| OnTriggerEnter |
Usertype: instancePhysicalObject: triggeredBy |
Called when the owner of this behaviour enter in trigger with another physical object | |
| OnTriggerStay |
Usertype: instancePhysicalObject: triggeredBy |
Called when the owner of this behaviour is in trigger with another physical object | |
| OnTriggerExit |
Usertype: instancePhysicalObject: triggeredBy |
Called when the owner of this behaviour exit from trigger with another physical object |
---@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 MoveUpDownNote
Ready to write some Lua code? Check out the scripting reference!