Ir para o conteúdo principal
Version: latest - a1.11.0 ⚖️

🪤 Trigger

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

info

🟦 Authority: This class can only be spawned on Server.

Inheritance: This class inherits from Base Actor.

Usage

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)
Package.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)
Package.Log("Something entered my Box Trigger")
end)

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

Constructor Parameters

TypeNameDefault
VectorlocationVector(0, 0, 0)
RotatorrotationRotator(0, 0, 0)
VectorextentVector(0, 0, 0)Size of the Trigger. If using Sphere, only the X is used
TriggerTypetrigger_typeTriggerType.SphereCurrently supports Sphere of Box
booleanis_visiblefalseUseful for debugging
ColorcolorColor.REDColor to paint the Trigger bounds - if Visible

Functions

Inherited Actor Functions
ReturnsNameDescription
AddImpulseApplies a Force in world space to this Actor
AttachToAttaches this Actor to another Actor
DestroyDestroys this Actor
DetachDetaches this Actor if attached
SetCollisionSets this Actor's collision type
SetForceAdds a permanent force to this Actor
SetGravityEnabledSets whether gravity is enabled on this Actor
SetVisibilitySets the Actor visibility
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
SetLocationSets this Actor's location in the game world
SetNetworkAuthoritySets the Player this Actor will have its physics calculated on Network Authority
SetRelativeLocationSets this Actor's relative location in local space
SetRelativeRotationSets this Actor's relative rotation in local space
SetRotationSets this Actor's rotation in the game world
SetScaleSets this Actor's scale
SetValueSets a value in this Actor, which can be accessed by any package
TranslateToSmoothly moves this Actor to the specified location
RotateToSmoothly rotates this Actor to the specified angle
booleanHasNetworkAuthorityGets if the LocalPlayer is currently the Network Authority of this Actor
booleanHasAuthorityGets if this Actor was spawned by the client side
booleanIsBeingDestroyedGets if this Actor is being destroyed
booleanIsGravityEnabledGets whether gravity is enabled on this Actor
booleanIsVisibleGets whether this actor is Visible or not
booleanIsInWaterGets if this Actor is in water
booleanIsNetworkDistributedGets if this Actor is currently Network Distributed
booleanIsValidReturns if this Actor is valid (i.e. not destroyed)
tableGetAttachedEntitiesGets all Actors attached to this Actor
anyGetAttachedToGets the Actor this Actor is attached to
tableGetBoundsGets this Actor's bounds
numberGetCollisionGets this Actor's collision type
numberGetIDGets the universal network ID of this Actor
VectorGetLocationGets this Actor's location in the game world
RotatorGetRotationGets this Actor's angle in the game world
VectorGetForceGets this Actor's scale
VectorGetScaleGets this Actor's scale
stringGetTypeGets the type of this Actor
anyGetValueGets a value stored on this Actor at the given key
VectorGetVelocityReturns this Actor's current velocity
stringAddActorTagAdds an Unreal Actor Tag to this Actor
stringRemoveActorTagRemove an Unreal Actor Tag from this Actor
tableGetActorTagsGets all Unreal Actor Tags from this Actor
functionSubscribeSubscribes to an Event
UnsubscribeUnsubscribes from an Event
ReturnsNameDescription
ForceOverlapCheckingForces a Overlap check to occur
SetExtentSets the extent size of this trigger

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)
TypeParameterDescription
VectorextentSphere triggers will use only the .X component for radius

Events

Inherited Actor Events
NameDescription
DestroyTriggered when an Actor is destroyed
SpawnTriggered when an Actor is spawned/created
ValueChangeTriggered when an Actor has a value changed with :SetValue()
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)

end)
TypeParameterDescription
TriggerselfThe Trigger entity
Base ActorentityAny Actor which overlaps

EndOverlap

Triggered when something leaves this Trigger

Trigger.Subscribe("EndOverlap", function(self, entity)

end)
TypeParameterDescription
TriggerselfThe Trigger entity
Base ActorentityAny Actor which left the Trigger