My program doesn't have bugs. It just develops random features.

Difference between revisions of "UE2:LineOfSightTrigger (UT2004)"

From Unreal Wiki, The Unreal Engine Documentation Site
Jump to: navigation, search
(Auto-generated page)
 
(added descriptions)
 
Line 5: Line 5:
 
| parent3 = Object
 
| parent3 = Object
 
}}
 
}}
{{autogenerated}}
+
The line-of-sight trigger fires an event if a player looks in the direction of a specified actor while being within a certain distance from the LOS trigger and having a clear line of sight to that actor. The distance limitation is relative to the LOS trigger's location, while the direction and line of sight is relative to the target actor location.
LineOfSightTrigger
+
 
triggers its event when player looks at it from close enough
+
'''Note:''' This actor only works offline and for the server player on a listen server, but not for any clients on a listen/dedicated server. It does not care whether that player actually participates in the game or is just a spectator.
ONLY WORKS IN SINGLE PLAYER (or for the local client on a listen server)
+
You could implement a multiplayer version using a tick function and PlayerCanSeeMe(),
+
but that would have more performance cost
+
  
 
==Properties==
 
==Properties==
Line 17: Line 14:
 
'''Type:''' [[bool]]
 
'''Type:''' [[bool]]
  
<!-- enter variable description -->
+
Whether the LOS trigger is ready to fire its event if the player sees it.
  
 
'''Default value:''' True
 
'''Default value:''' True
Line 24: Line 21:
 
'''Type:''' [[int]]
 
'''Type:''' [[int]]
  
how directly a player must be looking at SeenActor center (in degrees)
+
How directly (in degrees) a player must be looking at the center of the actor marked by {{tl|SeenActorTag}}.
  
 
'''Default value:''' 15
 
'''Default value:''' 15
Line 31: Line 28:
 
'''Type:''' [[float]]
 
'''Type:''' [[float]]
  
maximum distance player can be from this trigger to trigger it
+
Maximum distance player can be from the LOS trigger to activate it.
  
 
'''Default value:''' 3000.0
 
'''Default value:''' 3000.0
Line 38: Line 35:
 
'''Type:''' [[name]]
 
'''Type:''' [[name]]
  
tag of actor which triggers this trigger when seen
+
[[Match the Tag]] of an actor which activates this LOS trigger when seen with this property's value. The LOS trigger will not work if this doesn't match the Tag of an existing actor in the level.
  
 
===Internal variables===
 
===Internal variables===
Line 44: Line 41:
 
'''Type:''' [[bool]]
 
'''Type:''' [[bool]]
  
<!-- enter variable description -->
+
Whether the LOS trigger was already activated.
  
 
====OldTickTime====
 
====OldTickTime====
 
'''Type:''' [[float]]
 
'''Type:''' [[float]]
  
<!-- enter variable description -->
+
''Used internally.''
  
 
====RequiredViewDir====
 
====RequiredViewDir====
 
'''Type:''' [[float]]
 
'''Type:''' [[float]]
  
how directly player must be looking at SeenActor - 1.0 = straight on, 0.75 = barely on screen
+
How directly player must be looking at {{tl|SeenActor}}. 1.0 = straight on, 0.75 = barely on screen. This value is calculated automatically from the {{tl|MaxViewAngle}}.
  
 
====SeenActor====
 
====SeenActor====
 
'''Type:''' {{cl|Actor}}
 
'''Type:''' {{cl|Actor}}
  
<!-- enter variable description -->
+
The actor specified by {{tl|SeenActorTag}} that needs to be looked at in order to activate this LOS trigger.
  
 
===Default values===
 
===Default values===
Line 74: Line 71:
 
{{code|event '''PlayerSeesMe''' ({{cl|PlayerController}}&nbsp;'''P''')}}
 
{{code|event '''PlayerSeesMe''' ({{cl|PlayerController}}&nbsp;'''P''')}}
  
<!-- enter event description -->
+
Fires the LOS trigger's {{tl|Event||Actor properties}} the first time a player sees the trigger after it was enabled. If you want this function to be called again later, you need to manually set {{tl|bTriggered}} to ''False'' from another [[UnrealScript]] function as there's no way to do that automatically.
  
 
====PostBeginPlay====
 
====PostBeginPlay====
Line 81: Line 78:
 
'''Overrides:''' {{tl|PostBeginPlay|Actor|events}}
 
'''Overrides:''' {{tl|PostBeginPlay|Actor|events}}
  
<!-- enter function description -->
+
Initializes the {{tl|RequiredViewDir}} and {{tl|SeenActor}} variables from {{tl|MaxViewAngle}} and {{tl|SeenActorTag}} respectively.
  
 
====Trigger====
 
====Trigger====
Line 88: Line 85:
 
'''Overrides:''' {{tl|Trigger|Actor|events}}
 
'''Overrides:''' {{tl|Trigger|Actor|events}}
  
<!-- enter function description -->
+
Enables the LOS trigger. Once enabled, there is no way to disable it again, apart from manually setting the {{tl|bEnabled}} property to ''False'' from another [[UnrealScript]] function.

Latest revision as of 12:35, 20 December 2008

UT2004 Object >> Actor >> Triggers >> LineOfSightTrigger
Package: 
Engine
This class in other games:
UE2Runtime, UT2003, U2, U2XMP

The line-of-sight trigger fires an event if a player looks in the direction of a specified actor while being within a certain distance from the LOS trigger and having a clear line of sight to that actor. The distance limitation is relative to the LOS trigger's location, while the direction and line of sight is relative to the target actor location.

Note: This actor only works offline and for the server player on a listen server, but not for any clients on a listen/dedicated server. It does not care whether that player actually participates in the game or is just a spectator.

Properties[edit]

Property group 'LineOfSightTrigger'[edit]

bEnabled[edit]

Type: bool

Whether the LOS trigger is ready to fire its event if the player sees it.

Default value: True

MaxViewAngle[edit]

Type: int

How directly (in degrees) a player must be looking at the center of the actor marked by SeenActorTag.

Default value: 15

MaxViewDist[edit]

Type: float

Maximum distance player can be from the LOS trigger to activate it.

Default value: 3000.0

SeenActorTag[edit]

Type: name

Match the Tag of an actor which activates this LOS trigger when seen with this property's value. The LOS trigger will not work if this doesn't match the Tag of an existing actor in the level.

Internal variables[edit]

bTriggered[edit]

Type: bool

Whether the LOS trigger was already activated.

OldTickTime[edit]

Type: float

Used internally.

RequiredViewDir[edit]

Type: float

How directly player must be looking at SeenActor. 1.0 = straight on, 0.75 = barely on screen. This value is calculated automatically from the MaxViewAngle.

SeenActor[edit]

Type: Actor

The actor specified by SeenActorTag that needs to be looked at in order to activate this LOS trigger.

Default values[edit]

Property Value
bCollideActors False

Events[edit]

PlayerSeesMe[edit]

event PlayerSeesMe (PlayerController P)

Fires the LOS trigger's Event the first time a player sees the trigger after it was enabled. If you want this function to be called again later, you need to manually set bTriggered to False from another UnrealScript function as there's no way to do that automatically.

PostBeginPlay[edit]

event PostBeginPlay ()

Overrides: Actor.PostBeginPlay

Initializes the RequiredViewDir and SeenActor variables from MaxViewAngle and SeenActorTag respectively.

Trigger[edit]

event Trigger (Actor Other, Pawn EventInstigator)

Overrides: Actor.Trigger

Enables the LOS trigger. Once enabled, there is no way to disable it again, apart from manually setting the bEnabled property to False from another UnrealScript function.