Controlling node flow using a Gate action

In this recipe we'll change the way that the spawning of Bots, which occurs in a loop, is culled when a target number of 10 Bots have been spawned. In the previous recipe you learned to keep track of how many enemy Bots in the level have been killed by the player, with winning conditions occurring upon a desired total of 10.

Getting ready

Open the map Packt_04_GateAction_Start.UDK. The lesson continues on from the previous one. Note that in Kismet, for the scene, 1 can be set as a bookmark for the main sequence, 2 as a bookmark for the Sub-Sequence Enemies, and 3 as a bookmark for the Sub-Sequence EndSequence.

How to do it...

  1. The Sub-Sequence EndSequence is fired when an Integer Counter reaches a goal of ten Bot Death events. This is what we set up in the last recipe. Double-click on it to open it. Notice that it is set to fire off straight away a comparison called Is Alive which will Destroy any Bots from that point onward (if there are any). This loops, which works well, but it means there is a continual spawn of extra Bots and a culling loop behind the scenes.
    How to do it...
  2. To remedy this we'll instead use a Gate action to block the flow of Bots once 10 have been killed, instead of using the Is Alive condition. Select all the nodes in the Comment box Prevents More Bots after 10 die then press the Del key.
  3. Press the [ How to do it... ] icon to go the main sequence or press 1. Here, find the Int Counter node and next to it hold G and click to add a new Gate action. You can also right-click and choose New Action | Misc | Gate.
  4. The Gate action has and In nub and an Out nub. This lets you stream though it from one action or event to another. There are also Open and Close nubs. When one of these are set, the Gate opens and closes accordingly, based on whichever was set most recently. Hook the A == B nub of the Int Counter to the Close nub of the Gate action. Note that above the Gate there is text saying bOpen=True. This is the state of the Gate when the game begins. It can be set to false in the properties, but for this case, true is fine.
  5. Press Alt on the wire leading from the Remote Event KilledBot to the AutoIn0 nub of the Sub-Sequence Enemies.
  6. Instead, connect the Out nub of the Remote Event KilledBot to the In nub of the Gate action. Then connect the Out nub of the Gate action to the AutoIn0 nub of the Sub-Sequence Enemies. This change means a Bot can spawn through the loop through the Remote Event while the Gate is Open. Once 10 Bots have been killed the gate will Close, and no more will come forth. That means we no longer need to test the Is Alive condition for the Bot and cull extras. There won't be any.
    How to do it...
..................Content has been hidden....................

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