Skip to main content

Trigger

A Trigger class is a utility class to trigger events when any Entity enters an Area.


💂Authority
This class can only be spawned on 🟦 Server side.
👪Inheritance
This class shares methods and events from Base Entity, Base Actor.

Examples​

local sphere_trigger = Trigger(Vector(-200, 100, 500), Rotator(), Vector(100), TriggerType.Sphere, true, Color(1, 0, 0))

sphere_trigger:Subscribe("BeginOverlap", function(trigger, actor_triggering)
Console.Log("Something entered my Sphere Trigger")
end)

local box_trigger = Trigger(Vector(300, 200, 500), Rotator(0, 45, 0), Vector(150, 150, 150), TriggerType.Box, true, Color(0, 1, 0))

box_trigger:Subscribe("BeginOverlap", function(trigger, actor_triggering)
Console.Log("Something entered my Box Trigger")
end)

box_trigger:Subscribe("EndOverlap", function(trigger, actor_triggering)
Console.Log("Something left my Box Trigger")
end)

Constructors​

Default Constructor​

local my_trigger = Trigger(location, rotation, extent, trigger_type?, is_visible?, color?, overlap_only_classes?)
TypeNameDefaultDescription
Vectorlocation
Rotatorrotation
VectorextentSize of the Trigger. If using Sphere, only the X is used
TriggerTypetrigger_typeTriggerType.Sphere
booleanis_visiblefalseUseful for debugging
ColorcolorColor.REDColor to paint the Trigger bounds - if Visible
table of stringoverlap_only_classes{}Filter Trigger to only overlap specific Classes. Leave it empty for all Classes

Static Functions​

Inherited Entity Static Functions
Base Entityscripting-reference/classes/base-classes/Entity
ReturnsNameDescription
table of Base EntityGetAllReturns a table containing all Entities of the class this is called on
Base EntityGetByIndexReturns a specific Entity of this class at an index
integerGetCountReturns how many Entities of this class exist
iteratorGetPairsReturns an iterator with all Entities of this class to be used with pairs()
tableInheritInherits this class with the Inheriting System
table of tableGetInheritedClassesGets a list of all directly inherited classes from this Class created with the Inheriting System
table or nilGetParentClassGets the parent class if this Class was created with the Inheriting System
booleanIsChildOfGets if this Class is child of another class if this Class was created with the Inheriting System
functionSubscribeSubscribes to an Event for all entities of this Class
functionSubscribeRemoteSubscribes to a custom event called from server
UnsubscribeUnsubscribes all callbacks from this Event in this Class within this Package, or only the callback passed
This entity doesn't have own static functions.

Functions​

Inherited Entity Functions
Base Entityscripting-reference/classes/base-classes/Entity
ReturnsNameDescription
integerGetIDGets the universal network ID of this Entity (same on both client and server)
tableGetClassGets the class of this entity
booleanIsARecursively checks if this entity is inherited from a Class
functionSubscribeSubscribes to an Event on this specific entity
functionSubscribeRemoteSubscribes to a custom event called from server on this specific entity
UnsubscribeUnsubscribes all callbacks from this Event in this Entity within this Package, or only the callback passed
SetValueSets a Value in this Entity
anyGetValueGets a Value stored on this Entity at the given key
DestroyDestroys this Entity
booleanIsValidReturns true if this Entity is valid (i.e. wasn't destroyed and points to a valid Entity)
CallRemoteEventCalls a custom remote event directly on this entity to a specific Player
CallRemoteEventCalls a custom remote event directly on this entity
BroadcastRemoteEventCalls a custom remote event directly on this entity to all Players
Inherited Actor Functions
Base Actorscripting-reference/classes/base-classes/Actor
ReturnsNameDescription
AddImpulseApplies a force in world world to this Actor
AttachToAttaches this Actor to any other Actor, optionally at a specific bone
DetachDetaches this Actor from AttachedTo Actor
SetCollisionSets this Actor's collision type
SetDimensionSets this Actor's Dimension
SetForceAdds a permanent force to this Actor, set to Vector(0, 0, 0) to cancel
SetGravityEnabledSets whether gravity is enabled on this Actor
SetVisibilitySets whether the actor is visible or not
SetHighlightEnabledSets whether the highlight is enabled on this Actor, and which highlight index to use
SetOutlineEnabledSets whether the outline is enabled on this Actor, and which outline index to use
SetLifeSpanSets the time (in seconds) before this Actor is destroyed. After this time has passed, the actor will be automatically destroyed.
SetLocationSets this Actor's location in the game world
SetRotationSets this Actor's rotation in the game world
SetRelativeLocationSets this Actor's relative location in local space (only if this actor is attached)
SetRelativeRotationSets this Actor's relative rotation in local space (only if this actor is attached)
SetScaleSets this Actor's scale
SetNetworkAuthoritySets the Player to have network authority over this Actor
SetNetworkAuthorityAutoDistributedSets if this Actor will auto distribute the network authority between players
TranslateToSmoothly moves this actor to a location over a certain time
RotateToSmoothly rotates this actor to an angle over a certain time
booleanIsBeingDestroyedReturns true if this Actor is being destroyed
booleanIsVisibleReturns true if this Actor is visible
booleanIsGravityEnabledReturns true if gravity is enabled on this Actor
booleanIsInWaterReturns true if this Actor is in water
booleanIsNetworkDistributedReturns true if this Actor is currently network distributed
table of Base ActorGetAttachedEntitiesGets all Actors attached to this Actor
Base Actor or nilGetAttachedToGets the Actor this Actor is attached to
tableGetBoundsGets this Actor's bounds
CollisionTypeGetCollisionGets this Actor's collision type
VectorGetLocationGets this Actor's location in the game world
VectorGetRelativeLocationGets this Actor's Relative Location if it's attached
Player or nilGetNetworkAuthorityGets this Actor's Network Authority Player
RotatorGetRotationGets this Actor's angle in the game world
RotatorGetRelativeRotationGets this Actor's Relative Rotation if it's attached
VectorGetForceGets this Actor's force (set by SetForce())
integerGetDimensionGets this Actor's dimension
booleanHasNetworkAuthorityReturns true if the local Player is currently the Network Authority of this Actor
booleanHasAuthorityGets if this Actor was spawned by the client side
VectorGetScaleGets this Actor's scale
VectorGetVelocityGets this Actor's current velocity
AddActorTagAdds an Unreal Actor Tag to this Actor
RemoveActorTagRemoves an Unreal Actor Tag from this Actor
table of stringGetActorTagsGets all Unreal Actor Tags on this Actor
booleanWasRecentlyRenderedGets if this Actor was recently rendered on screen
floatGetDistanceFromCameraGets the distance of this Actor from the Camera
floatGetScreenPercentageGets the percentage of this Actor size in the screen
ReturnsNameDescription
ForceOverlapCheckingForces a Overlap checking to occur, will immediately trigger overlaps
SetExtentSets the extent size of this trigger (sphere triggers will use only the .X component for radius)
SetColorSets the Trigger color (if visible)
SetOverlapOnlyClassesSets the filter to Trigger to only overlap specific Classes. Leave it empty for all Classes

ForceOverlapChecking​

Forces a Overlap checking to occur, will immediately trigger overlaps

my_trigger:ForceOverlapChecking()

SetExtent​

Sets the extent size of this trigger (sphere triggers will use only the .X component for radius)

my_trigger:SetExtent(extent)
TypeParameterDefaultDescription
Vectorextent

SetColor​

Sets the Trigger color (if visible)

my_trigger:SetColor(color)
TypeParameterDefaultDescription
Colorcolor

SetOverlapOnlyClasses​

Sets the filter to Trigger to only overlap specific Classes. Leave it empty for all Classes

my_trigger:SetOverlapOnlyClasses(overlap_only_classes)
TypeParameterDefaultDescription
table of stringoverlap_only_classes

Events​

Inherited Entity Events
Base Entityscripting-reference/classes/base-classes/Entity
NameDescription
SpawnTriggered when an Entity is spawned/created
DestroyTriggered when an Entity is destroyed
ValueChangeTriggered when an Entity has a value changed with :SetValue()
ClassRegisterTriggered when a new Class is registered with the Inheriting System
Inherited Actor Events
Base Actorscripting-reference/classes/base-classes/Actor
NameDescription
SpawnTriggered when an Entity is spawned/created
DestroyTriggered when an Entity is destroyed
ValueChangeTriggered when an Entity has a value changed with :SetValue()
ClassRegisterTriggered when a new Class is registered with the Inheriting System
NameDescription
BeginOverlapTriggered when something overlaps this Trigger
EndOverlapTriggered when something leaves this Trigger

BeginOverlap​

Triggered when something overlaps this Trigger
Trigger.Subscribe("BeginOverlap", function(self, entity)
-- BeginOverlap was called
end)
TypeArgumentDescription
TriggerselfThe Trigger entity
Base ActorentityAny Actor which overlaps

EndOverlap​

Triggered when something leaves this Trigger
Trigger.Subscribe("EndOverlap", function(self, entity)
-- EndOverlap was called
end)
TypeArgumentDescription
TriggerselfThe Trigger entity
Base ActorentityAny Actor which left the Trigger