Today I’ve been trying to work around a problem I’ve been having with Unreal Engine. It’s surely just down to my lack of experience, but I’ve been having a hard time figuring out how to have the game recognise which players attached to which controllers want to start a game.

Up until now, the game assumed that all four players were playing, so spawned in four players every time the map was loaded. This was initially scripted in by me deliberately, as it was useful to have four players for early testing purposes, and it also allowed me to put off this problem until later.

The problem is that in Unreal Engine, you can’t deactivate controllers once they’re plugged in. If you tell the game to spawn pawns (player models) for every controller that exists (an earlier approach), it will work, but I realised that it’s not what I need. I want to be able to have various controllers physically plugged in, but allow the players to decide how many people are playing and on which controllers. Under the old approach, this wasn’t possible, short of pulling out controller cables when you wanted fewer players. Not ideal.
I realised today that if I start the game with all of the players activated in the select screen, but then let only the ones that are “ready” move on to the next scene/level when it’s loaded, then that might work. It seemed for a moment like I’d hit upon a unique solution to my problem, and then I realised that this is exactly the way that Samurai Gunn handles its player selection.

samuirai-gunn4
Samurai Gunn’s player select screen

After about 90 minutes’ work, here’s my initial attempt:

As you can see, it pretty closely resembles the selection screen from Samurai Gunn. I like the way that game allows players to get accustomed to the controls in that character selection period. If you’ve made a selection, you’re free to move around, jump, slash and fire your gun. Aside from this being useful for letting the player know which corner they are in, and for getting used to the feel of the controls, a beginner player is also able to notice from this screen that the gun will run out of ammo after three shots. I wanted to achieve a similar opportunity to show the player important stuff like this, so in my player select screen, once you’ve pressed start and your player pawn has appeared, you can move around your corner of the screen and fire your laser. If there’s anybody else also on screen, the laser will fire from their player model as well. I do plan on implementing a tutorial, but bearing in mind that many people don’t bother reading them, this is a pretty good way to communicate that mechanic in a safe environment before the real game has started and points are involved.

Update:

I managed to hook up the player selection screen to the actual game level. It was simple to make the actual level transition, but less simple was finding a way to carry the information of which players were marked as “ready” in the player select menu. I managed to solve the problem using  what Unreal calls a Save Game Object. You’re now able to set a controller as “ready”, and then when the game map loads, only the ready controllers will be selected to spawn. So now the game doesn’t assume you always want 4 players, which is great. I had been worrying about how I would solve this, and it turned out to be surprisingly painless.

 

Update 2: 

(03/07/2014)

I spent part of today improving the look and functionality of the player select screen. The placeholder text has been replaced by a light projection effect. It prompts the player to press start, and once they have, the text changes to show their player number. Also, the game will no longer allow a game to start with less than two people joined.

 

By zero51

Leave a Reply

Your email address will not be published. Required fields are marked *