Game Development Reference
In-Depth Information
How it works...
The
InteractionTrigger
instance has several things in common with
Enter-
ableTrigger
, which we created in the
Creating a trigger system
recipe, and it also has a
new functionality. Rather than firing the trigger as soon as the player enters it, it sets the
inside
flag, which defines whether it's possible to interact with it or not. It also displays
a text on the GUI for the player.
Once the
InteractionTrigger
receives a call to its
onAction
method from
In-
putManager
, it checks whether
inside
is
true
and calls
trigger
. To brush up your
knowledge on how input is handled, check out
Chapter 2
,
Cameras and Game Control
.