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...

  1. Begin by placing an AreaTrigger entity onto the map to use as the container for the Flow Graph.
  2. In the RollupBar, click on the Entities button.
  3. Under the Triggers section, select AreaTrigger.
  4. Right-click the newly placed AreaTrigger and create a new Flow Graph. Name the Flow Graph PlayerHealth.
  5. With the Flow Graph open and the new AreaTrigger selected, add in the following nodes:
    • Game:LocalPlayer
    • Time:Timer
    • Game:ActorGetHealth
    • HUD:DisplayDebugMessage
  6. 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.

  7. 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
  8. The resulting Flow Graph should look like the following:
    How to do it...

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.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
52.14.134.130