Displaying the player's health through a Flow Graph
Unfortunately, with the CryENGINE 3 SDK there is no current HUD element in place that displays the player's health out of the box. In this recipe, however, we will look at adding in a health display through the Flow Graph that will show the player's health in a numerical fashion.
Getting ready
Open My_Level.cry within the Sandbox
How to do it...
Begin by placing an AreaTrigger entity onto the map to use as the container for the Flow Graph.
In the RollupBar, click on the Entities button.
Under the Triggers section, select AreaTrigger.
Right-click the newly placed AreaTrigger and create a new Flow Graph. Name the Flow Graph PlayerHealth.
With the Flow Graph open and the new AreaTrigger selected, add in the following nodes:
Game:LocalPlayer
Time:Timer
Game:ActorGetHealth
HUD:DisplayDebugMessage
Set Time:Timer period to 0.05.
Note
You may also need to adjust the posX or posY on the HUD:DisplayDebugMessage if you have the Kill Counter as well.
Link the Flow Graph together as follows:
Game:LocalPlayer entityId out to Game:ActorGetHealth Choose Entity in
Time:Timer out out to Game:ActorGetHealth Trigger in
Game:ActorGetHealth Health out to HUD_DisplayDebugMessage Show AND message in
Game:LocalPlayer entityId out to HUD_DisplayDebugMessage Choose Entity in
The resulting Flow Graph should look like the following:
We should now see a numerical value of 100 in the upper-left corner of the screen the next time we enter into Game Mode on this level.
How it works...
Although this is kind of an expensive method of measuring the player's health, the timer is periodically getting the player's health (every 0.05 seconds) and outputting it to a HUD message for the player to read.