This tutorial is a bit more advanced and assumes that you have completed the Basic Tutorials so far. It takes Unreal's
TwinStick Shooter template, adds in a 2nd player, and modifies the controls to match Atari's classic, Combat!
You can download the project here to take a look. Please keep in mind that the implementation is quite bare-bones: basic controls, spawning projectiles, and handling collision. There's no UI, scoring system, or any visual fluff.
The main feature of this demo is that PlayerOne is scripted using while PlayerTwo is scripted using Blueprint graphs so you can easily compare scripts and nodes. Both players have exact mirror implementations.
First thing you'll notice when you open the project is that
PlayerOnePawn is a
PlayerTwo is an
Actor. This is just an workaround to allow two "players" to use one method of input; in this case, a keyboard. You can review the control mappings under
Edit > Project Settings... > Engine > Input:
PlayerOnePawn's BP class looks like this:
Hit the button in the toolbar to navigate to this BP's Skookum class and take a look at the methods and data members in there. At this point, you could also open
PlayerTwo's BP in and see how the graphical implementation in there compares to the scripts.
It's worth mentioning that we don't yet have auto-generation of all engine events (in this case, input events) and that is why we're still detecting input in
PlayerOnePawn's BP graph and then passing on the processing to . This is something that we'll be working on in the near future so you can do all logic and processing in alone and rely on BPs solely to edit your objects' spatial and graphical properties etc.
Make sure to check out the projectile classes in both and as well. Note that only
ProjectileOne's collision processing was moved into while leaving its
MovementComponent in . One can certainly write a coroutine to handle a projectile's movement frame-by-frame, but in this case, it was easier and quicker to just use a native component.
Questions? Comments? Have at it!
And as always, Stay Skookum!