Back in March I had the opportunity to go to GDC. It was a great time, I met a lot of cool people and a handful of Alumni from Champlain College. One of the most ask questions when I was there was, “Do you know Unreal 4?” Short answer, no, I don’t.
I do have experience with Unity, I have been working with it for a few years. One of the recent projects I am working on is a small side project called Bomb Bay. It’s a two player asynchronous multiplayer game, Where one player is a plane bombing the turrets on the island, and another player controls the turrets and try’s to shoot down the plane. Right now it’s nothing more than a simple prototype with four levels, but it’s a project I would like to take further. Here is some footage from the original unity version.
However, it’s far enough that I wanted to try to recreate a level in Unreal to run through. The main purpose of this is to become familiar with finding my way around Unreal and get familiar to the blueprints system.
One of the largest setbacks I faced was trying to do this project while finals were starting up and my capstone was nearing it’s end. Ideally I would like learn some more Unreal in my spare time, but for now I’d rather focus on the Unity version of Bomb Bay and some GCW projects.
In it’s current state in Unreal, Players can successfully pilot a plane and drop bombs, switch between turrets and shoot, and both can get destroyed.
The game itself is designed to be played splitscreen with one person on the keyboard and one person with a controller. In Unity, to get two screens to show up, I needed to have at least two cameras and change the viewport rect so they only take up half the screen. In Unreal, you don’t need to worry about the rectangles as long as you have two player controllers spawned in the world and the option for use splitscreen checked.Then you need to update the view target so the correct camera is being used. In the case of this game, each tower had their own camera that player two would switch between. In Unity it boiled down to activating and deactivating the cameras you want to use. Unreal does a similar thing in where you just set the view target and pass in which player controller and camera you want to set.
And just like that you have split screen in Unreal as long as you make sure to create an extra player at the start. By default, player controller 0 is already created. One thing I did seem to notice was that Create Player would return none, unless Spawn Pawn was checked.
Players and Pawns
The way Unreal works is that it uses Player Controllers. A player controller is what the players use to interact with the world. Each player controller is tied to their own inputs. So Player Controller 0 (PC0) would be tied to input from the first game pad, and Player Controller 1 would get input from the second gamepad. Pawns in the game are objects/actors that the players can control. They do this by possessing the pawn, as seen in the picture above. It makes sense that the inputs are tied to the Character controllers and if you are just using gamepad, everything is straight forward. My problem was that I was using both the gamepad and keyboard. The keyboard itself is always tied to the first player controller or Player Controller 0. And so is the first game pad. So here is the issue. in order to get split screen working, I need to have another player controller for player 2. But their input is tied to the second game pad plug in, so either I need to gamepads to play the game or find a way for PlayerController 0 to control the second player’s pawn.
I mentioned before that players take control of pawns by possessing them. But, they can only possess one pawn at a time. So the work around for that ended up being:
- Create Player 2, so that splitscreen exists
- Have Player 2 possess a pawn so the correct camera can be updated accordingly
- Have all the input go through player 1
- Give Player 1 a reference to current pawn controlled by player 2
- When Player 1’s controller receives input for player 2’s pawn, update accordingly
This is located inside the plane, even though it’s for the tower. I didn’t find out about the problem I would have with the input until after I put it all in the plane. So now it has the side effect of, if the plane gets destroyed, nothing currently handles input.
I know I barely even scratched the surface of Unreal with this project. But looking back at it I have already found many ways I can improve upon what i have implemented and I am excited to learn more about the engine. Until next time.