Trigger Component: Difference between revisions

From Pummel Party Mod Documentation
Jump to navigation Jump to search
(Added component settings and example usage)
(→‎Component Settings: Added Custom Collider and Center information)
 
(4 intermediate revisions by 2 users not shown)
Line 1: Line 1:
The trigger component is a [[:Category:Gameplay Components|gameplay component]] that fires [[Events]] when triggered. It will run any set [[Actions]] in response to those events.
The trigger component is a [[:Category:Gameplay Components|gameplay component]] that fires [[Event]]s when triggered. It will run any set [[Action]]s in response to those events.
It defines a trigger volume that is visible during editing of the mod, but is hidden in play mode.
It defines a trigger volume that is visible during the editing of the mod but is hidden in play mode.


== Component Settings ==
== Component Settings ==
[[File:TriggerComponent.png|thumb|500px|right|The Trigger component in the [[Inspector Window]].]]
{| class="wikitable"
{| class="wikitable"
|-
|-
Line 19: Line 20:
| style="padding-left: 2em;" | ''Capsule'' || The trigger is a capsule shape.
| style="padding-left: 2em;" | ''Capsule'' || The trigger is a capsule shape.
|-
|-
| style="padding-left: 4em;" | '''Radius''' || Distance from the center of the capsule to the edge.
| style="padding-left: 4em;" | '''Radius''' || Distance from the capsule's centre to the edge.
|-
|-
| style="padding-left: 4em;" | '''Height''' || Distance from the bottom of one curved end to the top of the other.
| style="padding-left: 4em;" | '''Height''' || Distance from the bottom of one curved end to the top of the other.
|-
|-
 
| style="padding-left: 2em;" | ''Custom Collider'' || The trigger uses the collider component(s) attached to this gameobject. <br/> Only 'Trigger on Hit' is available in this mode. Use the other modes instead if you want to use 'Trigger On Enter', 'Trigger On Exit' or 'Trigger On Stay'.
| '''Trigger On Enter''' || If this trigger should fire when something enters its volume.
|-
| '''Center''' || The center of the trigger in space. Use this to give the trigger an offset from the gameobject's position (Not available for Trigger Shape of ''Custom Collider'').
|-
| '''Trigger On Hit''' || This trigger fires when a weapon or punch collides with it. The trigger becomes solid when this setting is enabled, and the other trigger types are disabled.
|-
| style="padding-left: 2em;" | '''On Hit Actions''' || Actions to perform when something hits the trigger's solid collider.
|-
| '''Trigger On Enter''' || This trigger fires when something enters its volume.
|-
|-
| style="padding-left: 2em;" | '''On Enter Actions''' || Actions to perform when something enters the trigger volume.
| style="padding-left: 2em;" | '''On Enter Actions''' || Actions to perform when something enters the trigger volume.
|-
|-
| '''Trigger On Exit''' || If this trigger should fire when something exits its volume.
| '''Trigger On Exit''' || This trigger fires when something exits its volume.
|-
|-
| style="padding-left: 2em;" | '''On Exit Actions''' || Actions to perform when something enters the trigger volume.
| style="padding-left: 2em;" | '''On Exit Actions''' || Actions to perform when something enters the trigger volume.
|-
|-
| '''Trigger On Stay''' || If this trigger should fire repeatedly if something is within its volume.
| '''Trigger On Stay''' || This trigger fires repeatedly if something is within its volume.
|-
|-
| style="padding-left: 2em;" | '''On Stay Actions''' || Actions to perform when something enters the trigger volume.
| style="padding-left: 2em;" | '''On Stay Actions''' || Actions to perform when something enters the trigger volume.
Line 45: Line 53:


== Example Usage ==
== Example Usage ==
[[File:TriggerInSceneView.png|thumb|500px|right|The trigger as it appears in the [[Scene View]] when gizmos are enabled. Triggers are not visible in play mode; they are only visible while editing in the mod editor.]]


=== Damage area ===
=== Damage area ===
By having a trigger's On Stay event damage the activator of the trigger, you can create an area for players to avoid by constantly removing health while they are in the trigger. You could have the trigger kill the player who entered it, and attach the trigger to a moving object for the player to avoid (think an obstacle course with swinging blades).
By having a trigger's On Stay event damage the activator of the trigger, you can create an area for players to avoid by constantly removing health while they are in the trigger. You could have the trigger kill the player who entered it and attach the trigger to a moving object for the player to avoid (think an obstacle course with swinging blades).


=== King of the hill ===
=== King of the hill ===

Latest revision as of 20:59, 8 January 2023

The trigger component is a gameplay component that fires Events when triggered. It will run any set Actions in response to those events. It defines a trigger volume that is visible during the editing of the mod but is hidden in play mode.

Component Settings

The Trigger component in the Inspector Window.
Property Description
Trigger Shape The shape of the trigger volume.
Box The trigger is a box shape.
Size Describes the width height and depth of the trigger box.
Sphere The trigger is a sphere.
Radius Describes the width height and depth of the trigger box.
Capsule The trigger is a capsule shape.
Radius Distance from the capsule's centre to the edge.
Height Distance from the bottom of one curved end to the top of the other.
Custom Collider The trigger uses the collider component(s) attached to this gameobject.
Only 'Trigger on Hit' is available in this mode. Use the other modes instead if you want to use 'Trigger On Enter', 'Trigger On Exit' or 'Trigger On Stay'.
Center The center of the trigger in space. Use this to give the trigger an offset from the gameobject's position (Not available for Trigger Shape of Custom Collider).
Trigger On Hit This trigger fires when a weapon or punch collides with it. The trigger becomes solid when this setting is enabled, and the other trigger types are disabled.
On Hit Actions Actions to perform when something hits the trigger's solid collider.
Trigger On Enter This trigger fires when something enters its volume.
On Enter Actions Actions to perform when something enters the trigger volume.
Trigger On Exit This trigger fires when something exits its volume.
On Exit Actions Actions to perform when something enters the trigger volume.
Trigger On Stay This trigger fires repeatedly if something is within its volume.
On Stay Actions Actions to perform when something enters the trigger volume.
Trigger Interval Time in seconds between firing the On Stay event.
One Use Per Player Should this trigger only fire once for each player in the game.
Disable After Triggered Should this trigger disable itself after it is first triggered.

Example Usage

The trigger as it appears in the Scene View when gizmos are enabled. Triggers are not visible in play mode; they are only visible while editing in the mod editor.

Damage area

By having a trigger's On Stay event damage the activator of the trigger, you can create an area for players to avoid by constantly removing health while they are in the trigger. You could have the trigger kill the player who entered it and attach the trigger to a moving object for the player to avoid (think an obstacle course with swinging blades).

King of the hill

A king of the hill style game could be created by placing a trigger that rewards players for remaining inside it using actions with the On Stay event.

One use per player

Using the One Use Per Player attribute, you can make a trigger that can reward players with points, but stops players from repeatedly entering and exiting the trigger to gain many points.

Disable after triggered

Disable After Triggered can allow a trigger to only be usable by a single player. This can be used in minigames where to goal is to reach something first to win. You can make entering a trigger finish the game and reward the player as the winner by having the minigame win condition set to "Obtain Points" and the trigger's On Enter Action rewarding the number of points to win the game.