S2ENGINE HD
1.4.6
Official manual about S2Engine HD editor and programming
|
The player Character is the main element of the EasyGame pack. It owns an HUD inventory and manage it.
Player can perform a bunch of actions such as swimming, drive, turn off/on a lamp light, picking object using camera.
All these actions are notified using events, for example if player enter water and starts to swim an event PLAYER_START_SWIM is sent to its GameMachine FSM. In this way you can process these events as you want to build your player logic
Player Character is provided with a complex integrated HUD management system that also implements an inventory system. In order to make player character recognizing the HUD elements you must assign specific names to HUD elements basing on their behaviour.
As said Player also manages an internal inventory showing it on the HUD when pressing a button. User can specify what button must be pressed by using the parameter ActionCommand
.
The following is the pre-made HUD provided with the demo project and assets pack. In the image HUD element names are specified:
widgetClass
parameter in Widget Objects) and It must contains all the inventory elements. It is showed/hided by the player by using the ActionCommand
ItemCaption
parametermaxNumSlots
MaxCount
parameter of the Item prefab. Also you can specify that the item can be used indefinitely by making TRUE the unlimitedUse
parameter of the corresponding itemTAG.maxNumWeapons
outlineLowHealth
parameter of playerCharacter it becomes RED when health go low.outlineLowHealth
parameter of playerCharacter it becomes RED when health go low.Description
parameter of the mission objectShowSelected
button: The player character interfaces directly with its GameMachine FSM by sending events and receiving messages. For example when a player enter a car it sents the event ENTER_VEHICLE to its FSM. In this section we will explain all the events and messages the player character can receive and send.
PlayerCharacter do some actions replying to messages that are sent to it. For example if we sent a message "decrementHealth" to the playerCharacter we will see the HUD health indicator to decrease. Messages can be sent by FSM GameMachine using the action sendMessage. In the sendMessage action you can specify:
MessageName:
name of the message, in the example "DecrementHealth"MessageContent:
the content of the message if any. in the case of "DecrementHealth" message the content is the amount of energy to decreaseThe following are all the messages the playerCharacter process when receive them:
EnterWater:
It is a reserved message. It cannot explicitly sent by gameMachine FSM. It is sent by physics system when player enters waterExitWater:
It is a reserved message. It cannot explicitly sent by gameMachine FSM. It is sent by physics system when player exits waterENTER_VEHICLE:
It cannot explicitly sent by gameMachine FSM. It is sent to player when it pick a vehicle and performs the action command.EXIT_VEHICLE:
It cannot explicitly sent by gameMachine FSM. It is sent to player when it is just inside a vehicle and performs the action command.selectWeapon:
when playerCharacter receives this message it shows the weapon specified into the content and hides all the others. Also It sends an event to its FSM called "weapon_"+weaponName, where weaponName is the name of the selected weapon. This is a way to make FSM knowing what is the weapon in use. The weaponName is the name of the weapon object attached to the player model (see Weapons).USE_ITEM:
you can send this message when you want to force the player using a specified item. The content contains the item prefab player needs to recognize the item into the inventory. (see Items for more info about how items are used)UNLOCK_ITEM:
items can be locked, i.e. they cannot be used even if selected into the inventory. When you want to unlock a locked item you must send this message to player specify the item prefab into the message content. (see Items for more info about how items are used)HIDE_WEAPON:
send this message if you want to hide the current weapon (for example when player enters a vehicle). in the content the name of the weapon object. If you want to show the hided weapon send selectWeapon message.USE_WEAPON:
send this message when you want force the player to change the current weapon with the specified one. the content must contain the name of the weapon object.TAKE:
it is sent automatically by itemTAGs objects when player character pick them. This automatically inserts the related item into the inventory.ARM:
it is sent automatically by WeaponTAGs objects when player character pick them. this automatically inserts the related weapon into the inventorySUPPLY_AMMO:
it is sent automatically by WeaponAmmoTAGs objects when player character pick them. This automatically fill the related weapon AMMORechargeBattery:
It must be sent by FSM when you want the player recharge the battery of Lamp light. battery duration is specified by batteryDuration
parameter of player characterIncrementHealth:
It must be sent by FSM when you want the player increment its health. The content must be the amount of health of player (between 0 and maxHealth
)DecrementHealth:
It must be sent by FSM when you want the player decrement its health. The content must be the amount of health of player (between 0 and maxHealth
)LampON:
It must be sent by FSM when you want the player turn ON the lamp lightLampOFF:
It must be sent by FSM when you want the player turn OFF the lamp lightActionToPerform:
It cannot explicitly sent by gameMachine FSM. This message is sent by the AIMED object for making player to know what action to perform (open/close, take, etc..). These messages are sent by ItemTAGs, weaponTAGs, weaponAmmoTAGs, Vehicles and Switches class objects.The following are events that player (or other objects) sends to its FSM (and interacting objects FSM) when something happens (a pressed button, an item picking, etc..)
SHOW_INVENTORY:
it is sent to player FSM when user press the inventoryCommand
to show the inventory.HIDE_INVENTORY:
it is sent to player FSM when user press the inventoryCommand
to hide the inventory.MENU_SHOWED:
it is sent when to player FSM user press the menuCommand
to show the menu.MENU_HIDED:
it is sent when to player FSM user press the menuCommand
to hide the menu.PLAYER_START_SWIM:
it is sent to player FSM when player must start to swim, i.e. it enters a lake/sea area.PLAYER_END_SWIM:
it is sent to player FSM when player must end to swim, i.e. it exit from lake/sea area.CAMERA_ENTER_WATER:
it is sent to player FSM when the player camera enters a lake/sea area.CAMERA_EXIT_WATER:
it is sent to player FSM when the player camera exits from lake/sea area. It is useful to start the wet camera effect.CHANGE_WEAPON:
it is sent to player FSM when a weapon is selected from inventory or when the ChangeWeaponAxis
command is performed. See WeaponsTARGET_AIMED:
it is sent to player FSM when it aims an interacting object (the target, for example a switch, an iemTAG, a vehicle, ...). See also Items and WeaponsACTION:
it is sent to the aimed target when player performs the acion command (i.e. user press action button). See also Items and WeaponsAIMED:
it is sent to target object FSM when it aims an interacting object (the target, for example a switch, an iemTAG, a vehicle, ...). See also Items and WeaponsDIE:
It is sent when player reaches 0 healthWeapon_weaponName:
It is sent to player FSM after a weapon is selected,changed and showed. It is needed to know the current player weapon. WeaponName is the name of the weapon object attached to player model. See WeaponsThe player character automatically performs picking of the interactive elements of the scene.
There are 2 ways the player can interact with scene objects:
ActionRange
parameter of playerCharactercamera
parameter of PlayerCharacterThe first mode is usually used in 3rd person games, the second in first person games. By default player uses the By Aiming mode, but you can switch to By Range mode by put TRUE the ActionByRange
parameter of player character Usually the interaction works in the following steps:
The action button can be specified in the ActionCommand
parameter of the player character. It is an input action reference that can be configured using Input Mapping.
You can also choose to make player performing actions without pressing any button by put AutoAction
parameter to TRUE. This could be the case, for example, when you want to make an FPS in which player can take health simply by passing trough the health TAG.
The objects that can interact with player are ones belonging to the following classes:
switch:
included into S2BasePack dll. Note that EventSwitch
, AwakeSwitch
, ActivationSwitch
, MusicSwitch
, ShowSwitch
are all derived from Switch class, so they also can interact with player characteritemTAG:
included into S2GamePack dll.weaponTAG:
included into S2GamePack dll.vehicle:
included into S2BasePack dllweaponAmmoTAG:
included into S2GamePack dll.When a player aims one of these objects it sends to the aimed object an AIMED event (also a message) (see Player Sending Events).
The aimed object replies to player character with an ActionToPerform message (see Player Receiving Messages) that makes player to show what to do on the HUD (see HUD). Then, if user presses the action button, player character sends, to the aimed object, an ACTION event (also a message), that, depending on the object class produces different results:
Player can also drop items and/or weapons from inventory.
In this case the item slot count is decremented and the related itemTAG is instanced again into the scene, or, in the case of weapon, the weapon slot is empty and the related weaponTAG is re-spawned into the scene.
To make playerCharacter re-instancing the itemTAG / weaponTAG it is needed you create an itemTAG or weaponTAG prefab and put a reference to it from itemObject prefab or weapon, setting the TagPrefab
parameter (see Items, Weapons).