In Easy Game Pack Player character automatically interacts with active elements of the game, such as switches, doors, items or weapons to pick up, etc...
2 ways have been designed to make player character to interact with seen objects:
-
By Range: player interacts with all objects inside a specific range. The range can be specified by setting the
actionRange parameter.
-
By Aiming: player interacts with objects by performing a raycast from his camera, so to interact with an object camera must aim it. In this case you must specify the camera object by setting the
camera parameter.
The first mode is usually used in 3rd person games, the second in first person games. By default player character uses
By Aiming mode, by you can switch to
By Range mode checking the
actionByRange parameter of player character class.
The interaction works usually in the following way:
-
Player aims an interactive object (ot goes close to it)
-
You can also choose to make player performing actions, on all or on a subset of game objects, without pressing any button by setting the
autoActionMask parameter. This could be, for example, the case of a frenetic FPS in which you want the player to take health by simply pass upon a health
TAG.
The objects that can interact with the Player Character belong to the following classes:
| This doesn't happen when By Range mode is enabled.
|
Then, if the user presses the
action command button, the player character sends to the aimed object a ACTION event, and, depending on the aimed object class, this produces different results:
| From 2023 version playerCharacter can visualize the key/command to press when aiming an interactive object. In the case of Switches you must be sure that parameters "openActionText" and "CloseActionText" contain the string "com:action". Be also sure that parameter "LockedActionText" contains only a "space" character.
As result of this modification the playerCharacter now is capable to visualize the command to press for interact with aimed switches:
|
In this case the relating item slot count in the
Inventory is decremented (in the case of a weapon the weapon slot is emptied) and the relating
itemTAG (or
WeaponTAG in case of a weapon) is spawned again into the scene.
Player can drop either items and weapons from the
intentory and items and weapons from hands (see
Inventory for more info about how
handling works).