J’ai besoin d’aide avec ma carte : j’ai plusieurs messages HUD et je veux qu’un seul soit affiché à une équipe spécifique lorsqu’un déclencheur est activé, mais je veux également que le message HUD affiché soit randomisé à chaque tour.
Translation:
I need help with my map: I have multiple HUD messages and I want only one to be displayed to a specific team when a trigger is activated, but I also want the HUD message displayed to be randomized each round.
Op is doing an Imposter game where 1 player is chosen as the imposter and given a random word from an “Imposter Word” array. All other players are given a different word.
Example: Player 2 is chosen as Imposter and given the word “Manny”. All other players are given the word “Quinn”.
Were’ going to use the Game State to handle this. It has a copy of all player states, thus a reference to each controller. UI is typically handled in the controller class. So we get a win win here. An array of all players and reference to their controller.
Following GS code is executed on the server-side.
GS Functions:
Choose Imposter gets a random index from the GS Player Array. The index is stored in a server-side variable for gameplay condition logic.
Choose Words Selects a random word from the Imposter Words Array and sets a server-side sting variable. Then does the same for the safe word.
Server stores a copy to handle other gameplay conditional logic.
Update Players first loops the GS Player Array and calls a BP Interface event on the Safe Players. The Event passes the safe word and a boolean denoting imposter or safe.
Note we are excluding the chosen Imposters index.
Next we call the same Interface event on the chosen Imposters controller.
This is still all server-side.
BP Interface
Controller Class
Event Update Word (implement Interface Event) Sets the Word and Imposter State on the servers copy of the controller. It then calls an RPC (run on Owning Client) to pass the Word and State to its client.
Update Client Word sets the Word and State on the client-side. The Client now has their word and knows whether or not they are the imposter.
From here it’s just a matter of referencing the specific Widget and Setting Text for the given UI word variable.