-
Notifications
You must be signed in to change notification settings - Fork 262
Custom Scripts
Adrien Givry edited this page Feb 7, 2025
·
1 revision
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 onto the Scripts
folder in the Asset Browser window, click onto "New script...", enter a name and click enter.
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 |
-- Holds data that are shared between functions of this usertype
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