Ways to stop a recurring loop
In the previous recipe we created a swap between two Bots called Gremlin and Zombie. We can perform this swap all day and all night. Being able to jump back and forth forever might be a good dynamic in some games, but you might want to build in a way to prevent the swapping at a certain point, perhaps when a quest goal is reached or a mission objective achieved. It would be good to show how to interrupt the possession sequence. In this recipe we'll try out two methods, a New Action | Switch | Switch action and a New Action | Misc | AND Gate.
If Zombie shoots the gate shown here and dawn has arrived, the possession mechanism we set up in the previous recipe will stop. Instead a sliding gate (provisioned by a prefab) will open and Gremlin will start shooting at Zombie. There's our reason to use an AND Gate as both events must occur first. The problem is, as soon as the level begins it is dawn, we want to limit things so they player has to wait through the night...