Knockout Waiting Mechanic [ 🟧 3/10] (Ends Game - Respawns Players)

Are you editing? Don’t check for fun or you’ll end up like me:

Original Mechanic: Players wait for 30 sc when knocked out, then respawn, unless everyone is knocked out, in which case the game ends

Hi everyone,
I’ve seen the help topics like “How do I end game with one player left”, “Waiting area for knocked out players”, and I think this question needs a guide. This is especially useful for RPGs and dungeon crawlers, because it can let the player respawn at a set time, but end the game if everyone gets knocked out. It involves block code, triggers, counters, properties, and zones, but I think this guide could be followed by anyone. So to be clear, this guide will cover all the mechanics for a knockout waiting mechanic, where the game can end or the player can be respawned.

I originally got the idea for this after @Cosmicode posted a Help on Help on loss system for my dungeon crawler game. @Fwa and @Toxic helped out as well, so major thanks to them! And @wingwave helped with a malfunctioning mechanic in the guide, so thanks to them for that!

Also, instead of giving all of the answers at once, I’m going to try to walk through why the solution works and at the end, I’ll fix all the things that may have gone wrong, because it’s neat if people realize things for themselves. I will, however, add “notation” for the entire tutorial, so if you’re a more advanced GKC user, you don’t need to see screenshots and can just look at the settings for each device. Additionally, I’m adding the full tutorial as text at the bottom so if you need to check your work or something, you can just use that.

Level One: Zone and Spawning

To even make this mechanic possible, we need to figure out how many people are in the game. The easiest way to do this is to place a Zone over a Spawn Pad, next to a wall so it can’t be retriggered.

Here are the settings for the zone. Also, note that this system works best if you only have one spawn point in the game, because things will get complicated later on.

Player Enters Zone > Broadcast on Channel "Increase"

And finally, add a Checkpoint that’s just a little bit further away from the Spawn Pad so that if any players respawn, they won’t trigger the Zone again.

Settings for the Checkpoint:

Set as active checkpoint when receiving on > Increase
Level Two: Counting and Properties

To review, now we have a safe mechanic- a Zone that transmits when the players spawn in. Now, we need to get a “headcount”, if you will, of the players in the game.
In order to do this, place a Counter and a Property. Here are the settings for these two devices:

Property Name > "Players"
When property value changes, transmit on > "Players Amount" 

Increment counter when recieving on > "Increase"
Update Property > Yes
Property to Update > "Players"

Alright, so now we have a counter that increases by one for every player that joins the game. This connects to a property that will track the players in the game and will also transmit every time a player joins.

So now what? Well, now we need the actual mechanic itself: when a player is knocked out, they will teleport to a “waiting room” of sorts, where players will either respawn or if everyone is eliminated, the game ends.

Level Three: Knockouts and Teleporting

To check whether a player is knocked out or not, we need a lifecycle. Place it and set it to the settings below:

Events > Player Knocked Out
When event occurs, transmit on > "Player Out"

Great, so now when a player is knocked out, they get their very own special channel.

Now, here’s where I ran into an issue while testing: The player would teleport to the respawn area but would instantly spawn back to where their last checkpoint was, because the lifecycle transmits faster than the game. What you have to do is wire the lifecycle to a wire repeater with a delay of 0.5 seconds, then wire the repeater to the teleporter. This will work! Continuing on…

To make it the channel actually do something, place a teleporter and set it to the below settings:

When teleported here, transmit on > "Start Clock"
Teleport here when receiving on > "Player Out"

Alright, so now if a player is knocked out, they will teleport to this room. This is great! The mechanic is coming along nicely, but now if the player is knocked out, they will just stay in this room forever, which isn’t very fun.

Level Four: Counting and Properties (again)

Now we need something to happen when a player is in The Room. For this guide, we’re going to make it so the player is stuck in the room, waiting to respawn, for 30 seconds, after which they respawn. But if every player is eliminated, after that 30 seconds the game will end.
To start, place a Zone and size it to cover the entire room.

When player enters zone, transmit on > "Players Waiting"

Then, place a Counter and set it to increase by one on “Players Waiting”

Increment counter by one when receiving on > "Players Waiting"

Also, change the Counter to update a Property.

Update Property > Yes
Property to Update > "Players in the Room"

Now, obviously we need to actually place a property. Make sure it is, like before, a Number property:

Property Name > "Players in the Room"
Property Type > Number

So now, we have made it so when a player enters the room, they will increase a Property, which keeps track of the amount of people in the room. Next, we’ll set the clock for respawning and create the end game mechanic.

Level Five: Clocking and Respawning

If you remember Level Three, we created a channel for when the player is teleported to the room, which will start the clock. To make this guide more complicated (read: I forgot), we used a zone to count players, but you could’ve also just used that channel. Well, I guess it’ll be a fun time in the comments! Can’t… wait?

So now we need a 30sc timer in order to respawn the player. Place a trigger and set it to activate on Start Clock, then make it have a 30 second delay.

When triggered, transmit on > "Respawn"
Trigger when receiving on > "Start Clock"
Trigger Delay > "30"
Trigger by player collision > No
Visible in game > No

So when a player is sent to The Room, they will get yet another very special channel that activates after 30sc. Let’s make it do something!

Place a Respawn device and set it to respawn on the “Respawn” channel.

Respawn Triggering Player > "Respawn"

So now everything is magical and we have effectively created a delayed respawning mechanic. Now, we could have done this in one step, but everything else we’ve done is needed now, for the ending game step.

Place a trigger and set it to trigger on “Players Waiting”. What we’re trying to do is make it so that when all the players are knocked out, the game ends.

Trigger when receiving on > "Players Waiting"

Now, the part you’ve all been waiting for! Block code!

Boss Level: Block Coding

Create a new block in the trigger, set to “When triggered…”.
Now, copy in the below Block Code.


What this code does:
It compares the amount of players with the players who are currently knocked out, and if the two are equal, then all the players must be knocked out and the code will transmit on a game-ending channel.
To make the game end, add an End Game device and set it to end the game when receiving on “End Game”.

Fixing Things

There are couple of issues with the mechanic so far, though.
Here’s how to fix them!
You may have noticed that the counter for the players in The Room never resets, so if players are knocked out and then respawn a couple of times, it could still be considered that all the players are knocked out. To fix this, change the settings in the counter as follows:

Now, when a player respawns, the counter will decrease by one, so the amount of players in The Room is always accurate.

Bonus Level: Time, Text, and Trigger Code

There are a couple more things you can do to make the entire mechanic a little more interesting. Everything here is optional- think of these as add-ons for your knockout system :smiley:

I won’t go into as much detail for these mechanics, but if you have any questions feel free to comment.

Showing Respawn Time

When players are waiting to respawn, it’d be nice for them to have something to look at. Obviously, you could put a few props in the room to match the style of your game, but in this example, we will be looking at how to show the time left to respawn as an overlay on the map.
Note: Why an overlay? Well… it seems neat. You can also place text in the room, just make sure you set the scopes to player.

Start by placing an overlay. Set all the scopes to Player, because the respawn time is usually different for every knocked out individual. Additionally, set it so it is not active at game



Overlay Type > Text
Overlay Position > Top Right
Visible on Game Start > No
Show overlay when receiving on > "Player Out"
Hide overlay when receiving on > "Respawn"
Content Scope > Player
Visibility Scope > Player

To make the overlay actually do something, we have to create a timer.
(This was the absolute hardest part of the guide for me to write for some reason. Timers freak me out. Continue on without me)
Here’s how we’re going to go about this:

takes a break, does some homework, procrasinates…
tries to figure it out himself
gives up and uses someone else’s guide
too long, I’m going to figure this out!

I figured it out on my own!
Place a repeater and set it to the below settings:


Make sure to set the repeater to stop after receiving on channel “Reset”, as this was messing up the clock. Also, I’d strongly suggest using a trigger clock instead of this if you’re more comfortable with GKC devices.
Then, place a counter and set it to decrease by one when receiving on channel “Seconds”. It will also update a property, that property being known as “Clock”.

Starting Value > "30"
Decrement the counter when receiving on > "Seconds"
Count Scope > Player
Update Property > Yes
Property to update > "Clock"

Now, place a property (big surprise, I know) and set it as follows:

Property Name > "Clock"
Property Type > Number
Default Value > "30"
Property Scope > Player

So now we have a functioning countdown clock- it begins to count down from 30 seconds as the player is teleported and it can is safely stored in a property. We need a way to display it, and that’s where the overlay comes in. And this issue will crop up later, but we need a way to reset the clock and hide it after the player respawns. We’ll tackle the overlay first, because don’t we all just love block code?

In the overlay settings, click on Blocks and create a new “when recieving on channel” block, set to “Seconds”

Then, paste in this code!


Now, we have a functioning clock that will display for 30 seconds, showing the time left before a player respawns. The only issue is it will keep counting down after the player respawns. To fix this, just change the counter settings to give it a target of zero, and when it reaches that target, it will reset.

Use Target Value > Yes
Target Value > "0"
When target reached, transmit on "Reset"
Reset counter when receiving on "Reset"

The count-down clock is now functioning as it should!

Activity Feed Message

This one is the easiest, and it costs like no memory. Here we go!
In the trigger that has the code that checks for players who are in the respawn area (the one that triggers on “Player Out”, add on to the code like this:


And there you have it! The player who is respawning gets an extra knockout message. I don’t even know why I made this one, heh heh.

Levels 1-5 + Boss Level
Place a Zone over the Spawn Pad
Player Enters Zone > Broadcast on Channel "Increase"

Place a Checkpoint further away
Set as active checkpoint when receiving on > Increase

Place a Property
Property Name > "Players"
When property value changes, transmit on > "Players Amount" 

Place a Counter
Increment counter when recieving on > "Increase"
Update Property > Yes
Property to Update > "Players"

Place a Lifecycle
Events > Player Knocked Out
When event occurs, transmit on > "Player Out"

Now, here’s where I ran into an issue while testing: The player would teleport to the respawn area but would instantly spawn back to where their last checkpoint was, because the lifecycle transmits faster than the game. What you have to do is wire the lifecycle to a wire repeater with a delay of 0.5 seconds, then wire the repeater to the teleporter. This will work! Continuing on…

Place a Teleporter
When teleported here, transmit on > "Start Clock"
Teleport here when receiving on > "Player Out"

Place a Zone over Teleporter
When player enters zone, transmit on > "Players Waiting"

Place a Counter
Increment counter by one when receiving on > "Players Waiting"
Update Property > Yes
Property to Update > "Players in the Room"

Place a Property
Property Name > "Players in the Room"
Property Type > Number

Place a Trigger
When triggered, transmit on > "Respawn"
Trigger when receiving on > "Start Clock"
Trigger Delay > "30"
Trigger by player collision > No
Visible in game > No

Place a Respawner
Respawn Triggering Player > "Respawn"

Place a Trigger
Trigger when receiving on > "Players Waiting"
Add a Block "When triggered"

If ((Get Property "Players)=(Get Property "Players in the Room"))
Then (Broadcast Message on Channel "End Game")

Please let me know what I can improve on! I’m sure I forgot something, but I spent like five hours on this so hopefully it works pretty well. Here are some polls, for your trouble! (You better have read the guide if you’re voting). Anyways, that concluded the Knockout Mechanic guide. I really want to add more over time, so maybe I’ll ask 2468 to make this a wiki when they get back… there are so many variations and different ways… but this will do for now!

Polling Time!

Difficulty of Guide
  • 1/10
  • 2/10
  • 3/10
  • 4/10
  • 5/10
  • 6/10
  • 7/10
  • 8/10
  • 9/10
  • 10/10
0 voters
Quality of Guide
  • Stars above, this guide was amazing!
  • :star::star::star::star::star:
  • :star::star::star::star:
  • :star::star::star:
  • :star::star:
  • :star:
  • Well, @GlowingTurtle really messed up this time…
0 voters

Here is some “recommended reading” for this topic. I didn’t look at them when writing, but I will link them because they are kind of similar to this one and they’re good guides.

11 Likes

nice formatting and guide

your like a mix of everything good about this place

2 Likes

Nice guide… [1]


  1. But why did u post it if one part doesn’t work :confused: ↩︎

Because I can’t figure it out for the life of me…

@GlowingTurtle you only get 1 day of editing time as a basic so this will need to become a wiki

Hey… Thanks for the mention! Nice guide.

1 Like

This got buried kind of fast, so I know we’re not supposed to bump things to fast but I do want some more people to see it.
And I still need a little help with the overlay thing…

What’s the problem?

Edit: I read the text.

Also, if you want a more efficient player counter, then you could do something like:
Lifecycle → relay → counter

1 Like

Oh, thank goodness! I’m saved!
So, I have an overlay that activates when the player respawns. It starts counting down from 30, and it’s supposed to go away (deactivate) when the player exits the waiting area…But it doesn’t, and it starts going into the negatives even though it’s set to reset on the “Respawn” channel.

1 Like

Also… what tags does this belong in? Because it is kind of technical…?

Nah, technical is for like wire cutting, keybinding, etc.

battle-royale would be good.

I’m surprised that your method doesn’t work. What I’d do is have a counter with a property, say, timeLeft, have a starting amount of 30 and count down every second (using a trigger loop), like the timer. Then, the overlay also updates every second to match the property (use the create text: get property blocks). Then, the counter would have a target value of 0, and it broadcasts on channels to stop the trigger and reset the counter back to 30. Then, when the player respawns again, it’ll start the trigger and everything can keep working as supposed to.

3 Likes

You described almost exactly what I have. The only thing that’s different is… oh, I see!
Okay, I’m going to try this.
I’ll credit you in the guide if it works, thanks!

1 Like

Yeah, no problem.

Wow nice guide @GlowingTurtle! I can see you put a lot of effort into it

2 Likes

Lovely guide mate! Rather chipping! Tea and biscuits!

Dang it, have you been watching the Great British Baking Show again?

yes

Sigh, anyways, nice guide!

2 Likes

I just made your topic a wiki as it is a detailed guide and generally nice and detailed.
Good job on the guide.

1 Like

Hey @qfw, you said this guide wasn’t great. Would you mind saying why, as I can’t get better if I don’'t know what I did wrong. Thanks!

@Karlz, you were very naughty.
Don’t check the box for fun!
Alright, well…
Next time I won’t be as lenient…
(also, I get notified whenever someone checks the box, so there’s no hiding from me)

I unchecked it!
I didn’t mean to!

1 Like

oh sorry… It was my baby sister…

2 Likes