Hey @QUIVERYTACORN849 how are you?
For the voting system, there are two different approaches:
- Voting UI: with this one, each player will access to an independent voting screen
- Voting buttons: this is a more physical method, with buttons and counters for the votes
I highly recommend you to watch the following tutorials to chose what you want!
Voting UI
Voting Buttons
Both of them will certainly allow you to choose between different options. To make your maps be those options, you will need to create all those maps on the same island and then do something like this:
-
Create one map/room to use it as Starting/Voting Room:
In this room you will place enough Player Spawners for every player (all of them enabled from start) and all the voting system. -
Create your playable maps:
You will need to place enough Player Spawners for every player (all of them disabled from start) on all your maps, you will enable and disable them later based on the voting system. -
In your Verse code for the voting system, you will need to create an array of Player Spawners for each map (including the Starting/Voting Room)
-
When the voting session is over, what you want to do is to execute the code to choose the murderers (you can use the code from this post)
-
After choosing the murderers, what you will need to do is to move all the players to the corresponding map. To do that, you need to implement the following variables and functions:
The variables:
# Stores the location where the player will be teleported
var SpawnLocation : vector3 = vector3{}
## You can add as many maps as you want, but you need to add an editable array for each of them here
# Spawners Map 1
@editable
Spawners1 : []player_spawner_device = array{}
# Spawners Map 2
@editable
Spawners2 : []player_spawner_device = array{}
# Variable to set the chosen map after the voting session
var ChosenMap : int = 0
# Button that triggers the teleportation action
@editable
MyButton : button_device = button_device{}
When the voting is complete, you need to update the “ChosenMap” variable with the corresponding map number, which will be used in the “StartRoundOnChosenMap”.
Functions:
StartRoundOnChosenMap(Agent:agent):void=
# Calls the corresponding function based on the ChosenMap
case ( ChosenMap ):
# If random result is 1, teleport using Spawners1
1 => TeleportToRandomSpawner(Spawners1)
# If random result is 2, teleport using Spawners2
2 => TeleportToRandomSpawner(Spawners2)
# Fallback case (should never happen)
_ => {} # Do nothing
TeleportToRandomSpawner(PlayerSpawners : []player_spawner_device):void=
# Retrieve all players inside the playspace
AllPlayers := GetPlayspace().GetPlayers()
# Loop through all participants
for (Player : AllPlayers):
# Convert the participant into a FortCharacter (only valid if they are an active character)
if (FortChar := Player.GetFortCharacter[]):
# Only proceed if the spawner list is not empty
if (PlayerSpawners.Length > 0):
# Choose a random index within the list of spawners
RandomIndex := GetRandomInt(0, PlayerSpawners.Length - 1)
# Retrieve the spawner at that index
if (RandomSpawner := PlayerSpawners[RandomIndex]):
# Extract the spawner's world position
set SpawnLocation = RandomSpawner.GetTransform().Translation
# Move the teleport position slightly upward to avoid collisions with the ground
set SpawnLocation = SpawnLocation + vector3{X := 0.0, Y := 0.0, Z := 120.0}
else:
# Fallback location if there are no spawners configured
set SpawnLocation = vector3{X := 0.0, Y := 0.0, Z := 0.0}
# Teleport the character to the chosen location with default rotation
if(FortChar.TeleportTo[SpawnLocation, IdentityRotation()]):
You need to add all the maps to the Case in the “StartRoundOnChosenMap” function and put the corresponding array between parenthesis in each case.
That function should be called immediately after the murderers selection functions end.
- The last thing you need to do is to set the arrays on your island. Drop the device on your island and fill the arrays with the corresponding Player Spawners.
And that’s it! It should work as you want!
Please let me know if you need more help!