Randomized Individual Spawns 🟨 (Box Fights)

In game modes such as box fights players need to randomly spawn in their own box. With the new update this system can be now optimized which is what will be described here today.

Introduction

To accomplish random unique spawns we will use a random integer to determine the box. However we need to be able to not generate the same number used for the last player. This is so two players don’t end up in the same box. Essentially we are checking for exceptions to teleporting the player to their box however when generating a random integer we cannot choose numbers as exceptions during the generating[1]. We have to check for exceptions after.

For this guide you will need a live player counter to see if all players are readied up. I suggest you follow this guide right here. How to make a live player counter

Part 1 - Setting Spawns

First Grab a property. Name it “ExceptionsList”. Its settings should be default. Duplicate that property and name it “Spawn#”. Make it a number variable with a scope of player. Duplicate that property and name it “ReadyUp”. Change the scope to global and have it broadcast on “ReadyUpdated” when the value changes. Now duplicate the property and rename it “Live Players.” Those properties should look like this.

Now get a counter and have it be invisible in-game and increase when receiving on the channel “ReadyUp”. It should also update the property ReadyUp. It should look like this.

Go to the counter used in your Live player counter. Link it the the property “Live Players” Now grab a trigger. Change it to invisible in game and turn player collision off. It should receive on the channel “ReadyUpdated”. In block code put the following code.
Screenshot 2024-01-24 12.03.08 PM

Get a life cycle that is wired to a relay. The relay should receive on “Begin Set Spawns” and broadcast on “Set Spawns.” Now grab a trigger. Change it to invisible in game and turn player collision off. It should receive on the channel “Set Spawns”. In block code put the following code.
Screenshot 2024-01-24 11.17.18 AM
IMPORTANT - make sure you change the random integer from 42 to the number of boxes you have

This code generates the random number for a player’s spawn. It then uses the new blocks to check if that number is included in the exceptions list property. If it isn’t included it will set the player scoped property “Spawn#” to the random number. It then adds the spawn number to the “ExceptionsList”.

We have now accomplished making a system that will give each player a random spawn with no duplicates. This system is run on the channel “Begin Set Spawns.”

Part 2 - Teleporting to Spawns

The next thing you need is to make your boxes. In each box put one teleporter; these teleporters should be numbered in a grid and teleport player there when receiving on the channel “Box” + its number on the grid. Here is an example layout.
Screenshot 2024-01-24 12.12.19 PM

Get a relay. Have it receive on “SpawnAll” and broadcast on “SpawnIn” Now get another trigger. Set it to player collision off, and visible in game to no. Make the trigger receive on “SpawnIn.” in block code put the following.
Screenshot 2024-01-24 12.22.54 PM

We have now accomplished making a system that will teleport players to a random unique box after spawns are set. This system is run on the channel “SpawnAll”

Part 3 - Multiple Rounds

If your map needs to call the randomized spawns again (such as multiple rounds in box fights) you are going to want to add a few more things.

Go to your counter that updates the property “Ready Up.” Have it reset upon receiving on the channel “ResetSystem.” Now place a trigger[2] that is invisible in-game and cannot run on collision. It should also receive on “ResetSystem.” In block code it should set the property “ExceptionsList” to a blank text box with nothing in it.

Conclusion and Further Optimization

When you want to start another round you broadcast on “ResetSystem” to get the system ready to run again. Next you broadcast on “Begin Set Spawns.” Once the spawns are set (detectable upon receiving on “SpawnSet”) you can broadcast on “SpawnAll.”

Optimization 1

Broadcasting on three channels seems annoying. This can actually be condensed. Your random spawn can be set in the middle of a round since it is simply updating a property. Resetting properties can also happen in the middle of a round. Also if you are resetting these properties you are doing so with the intention of later setting the spawns and since setting spawns mid round doesn’t affect anything you can actually call “Begin Set Spawns” in the block code of the trigger (footnote 2) that resets the ExceptionsList. If you optimize it like so when the round starts you can simply broadcast on “ResetSystem” and then be able to call “SpawnAll” and start a new round whenever the round finishes.

TL;DR - make trigger that resets ExceptionsList also broadcast on “Begin Set Spawns”

Optimization 2

When starting the game you cannot “pre-load” the spawns as you normally can while players are actually playing during the round. This is only bad because if you try to broadcast on “Begin Set Spawns” and then “SpawnAll” before all players spawns are set a few players will not teleport and will end up excluded from your round. This is why there is the property “Ready Up” it checks to see if everyone has their properties set and then broadcasts on the channel “SpawnsSet.”

TL;DR - when starting the game broadcast on “Begin Set Spawns” and then broadcast on “SpawnAll” only after receiving on “SpawnsSet”

Difficulty Poll

  • 0/10 :white_large_square:
  • 1/10 :blue_square:
  • 2/10 :green_square:
  • 3/10 :green_square:
  • 4/10 :yellow_square:
  • 5/10 :yellow_square:
  • 6/10 :orange_square:
  • 7/10 :orange_square:
  • 8/10 :red_square:
  • 9/10 :red_square:
  • 10/10 :purple_square:
  • 11/10 :black_large_square:
0 voters

For the Reader

This forum has a like button for a reason. If you Did read my post and appreciated it, leave a like. If you have a question about troubleshooting this guide then you can reply but I do not want empty comment posts such as “oh nice guide” or “This is really useful.” If you want to compliment at least make it meaningful and unique if not the like button is plenty. This is even part of the forum FAQ and Rules.*

By replying to this guide you acknowledge that you have read this whole guide, have an understanding of the replies and are not about to leave an empty comment.

Thanks,

@TorontoBulls1


  1. This leads however to the hypothetical chance that the generated number is never the number needed to progress infinitely locking you in the situation where this system, or any others that rely on this will every work. However this probability is infinitely zero and realistically impossible to happen :grin: ↩︎

  2. further optimization happens with this trigger later ↩︎

9 Likes

Nice guide @TorontoBulls1! Not many people make detailed guides like this! THough if you had random abilities it would just be easier to use a variable and then make it like power, 1 - 8 or something and then if 1 broadcast on freeze. Then you can put a team switcher so like switch to team 1 if freeze

1 Like

Yeah this is just a guide on how to make sure people don’t get teleported into the same Box and how to make that random. Making powerups for Box fights is a different thing but I’m not sure if there is a guide on the forum.

1 Like

isnt there an easier way to do this?

I haven’t found one. This isn’t really that hard but I always make my guides super in depth so the word count is kinda scary buts its really something like
3 lifecycles
3 properties
3 triggers
1 counter
And then the live player system
Oh and the like 20 or so teleporters

I dont understand is this what the block code should look like on the one trigger?
image

Uh its so much easier to make random spawns and make it individual 0_o

Nope. (I think.)

Randomized teleporters dont work. They always go to the same place. All you need is a randomizer, and teleporters. (random teleporters are like transmitting a channel and then having 3 dif teleporters that receive the same channel, it will go the same one)

1 Like

uh… How to: Random Teleportation | 3/10

same thing he did, with randomizers. I think he just made it look different.

and seemily more complicated

Yeah, but I think they are both the same, just one is explained more differently. But oh well, we should stop arguing.

1 Like

Well… Okay. Final words are, I would rather do my simpler way than his way

1 Like

Your way is truly random but doesn’t include checking to see if only one player spawns there. This means you could have two people spawn at the same spot

2 Likes

Bump