Skip to content

Mod Hooks

Overview

Script Components can be added to Game Objects in Unity and exported in Asset Bundles IF they match a script in the base game code. These intentionally exportable scripts are referred to as Mod Hooks. They can be imported into a Unity project from the Project.unitypackage, and added to game objects inside the Unturned components menu. Each script makes several Events available which can drive other component properties like visibility or play an animation.

Each script documents its purpose and members within its *.cs file.

Cite

Originally proposed and coined by VitaxaRusModding in this GitHub issue: Link

Event Listeners

Activation Event Hook

Events when a component or game object are enabled and disabled. Useful for extending toggleable actions in the base game.

Collision Event Hook

Events for player overlaps with a trigger collider. Primarily useful for server-side objects as collisions are not triggered by other players client-side, but this limitation may be resolved in the future.

Destroy Event Hook

Invoked when a GameObject or component is removed from the scene.

Interactable Object Binary State Event Hook (IOBS)

(IOBS for short) are any prop placed from the level editor which can have F pressed on them to open, close, turn on/off, etc. This hook can be added to any GameObject within an IOBS to trigger events during state changes, and even control the IOBS from client and server side.

Text Chat Event Hook

Event when a text chat message passes certain filters such as channel, within a radius, and containing a secret phrase.

Info

These events are fired on the server.

Timer Event Hook

Allows events to set or cancel a timer, and triggers an event when the timer expires.

Vehicle Event Hook

Events for driver entering and exiting the vehicle.

Info

These events are fired on the server and client.

Vehicle Turret Event Hook

Events for when Turret_X gameobjects are used.

Info

These events are fired on the server and client.

Weather Event Hook

Events for day, night, full moon, and weather.

Info

These events are fired on the server and client.

Custom Weather Event Hook

Events for a specific custom Weather Asset. Any map can have an unlimited number of weather types and weather listeners.

Event Instigators

Client Text Chat Messenger

Allows Unity events to request a text chat message be sent on behalf of the client. For example, to execute a command.

Warning

The UnityEvents.Allow_Client_Messages and/or UnityEvents.Allow_Client_Commands settings must be enabled in the server Config.json file before these can be triggered. This ensures hosts are aware of their usage. Singleplayer defaults to enabled.

Server Text Chat Messenger

Allows Unity events to broadcast messages from the server. Icons and rich text are optional. Can also execute commands that are not available (yet) to NPCs like changing the weather or triggering an airdrop.

Warning

The UnityEvents.Allow_Server_Messages and/or UnityEvents.Allow_Server_Commands settings must be enabled in the server Config.json file before these can be triggered. This ensures hosts are aware of their usage. Singleplayer defaults to enabled.

Effect Spawner

Allows Unity events to spawn effect assets. When the AuthorityOnly field is enabled only the server will spawn effects and replicate them to clients.

Misc

Fall Damage Override

Allows any game object to override the fall damage when a character lands on it or one of its descendants.