Rewarding the player for reaching a kill goal

This recipe is a slight extension to the previous one. There are plenty of ways that the designers may want to reward the player in their title, but in this recipe, we will look at getting the player to kill five Grunts using just melee and then reward them by giving them a SCAR assault rifle.

Getting ready

  • You should have completed the Creating a kill counter recipe
  • Then open My_Level.cry within the Sandbox

How to do it...

  1. Open the KillCounter AreaTrigger Flow Graph and add in the following flow nodes:
    • Game:LocalPlayer
    • Math:Equal
    • Inventory:AddItem
  2. Set Math:Equal B to 5.
  3. Link the Flow Graph together as follows:
    • Math:Counter count out to Math:Equal A in
    • Math:Equal true out to Inventory:AddItem add in
    • Game:LocalPlayer entityId out to Inventory:AddItem Choose Entity in
  4. The end resulting Flow Graph should look like the following:
    How to do it...kill goalplayer achievement, rewarding

    Note

    The Kill Counter and Kill Goal colored boxes around the nodes are comment boxes. To add a comment box, right-click in the Flow Graph and click Add Comment Box.

How it works...

Branching off the Kill Counter, we can use the Math:Counter to find what kill number the player is at. Using the Math:Equal node, we can run a simple comparison to any value we please and in this example we used 5. So as soon as the Math:Counter reaches a value of 5, the Math:Equal node outputs a true statement and allows the SCAR to be added to the player's inventory.

See also

  • The Creating a kill counter recipe
..................Content has been hidden....................

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