Survival Sample Game: Section 6
Template:Rating C++ Sample project covering common gameplay concepts packed in a small coop survival game.
- 1 Introduction
- 2 Links
- 3 Feature Highlights
- 4 Available Maps
- 5 Coop and Open World
- 6 Taking this project beyond
- 7 Special Thanks
- 8 Closing
Section 6 is the conclusion to the C++ Survival game series. The final series is upgraded to support the latest 4.8 version of Unreal Engine. It introduces a new coop landscape map along with many tweaks and bug fixes. In this final section I will go over some of the available features in the project and give you some tips on building your own game using this series.
During the course of the 6 sections I covered a variety of C++ gameplay concepts for you to explore and learn from. Not all available features in the project were covered in the section documentation. I invite you to play the game and explore the source to discover everything that was included! To help you get an overview of what is available, I'm highlighting some of the project features below.
Weapons & Equipment
Players spawn with an assault rifle and a flashlight. These weapons can be carried on the character's back (rifle) and pelvis (flashlight) using Sockets. One of the more advanced features included is the custom AnimNotify that calls for the exact moment during the animation we must switch the mesh from being in the character's hands to his back or pelvis. Any time you specify an AnimNotify in your animations you can implement this event in the EventGraph of the AnimationBlueprint for that character.
Advanced Animation Blueprint
The project includes an advanced animation blueprint setup for the player character. It includes sprinting, crouching, aiming down sights, weapon fire recoil, etc. along with a special "Idle Break" animation that is played whenever a player idle for a small period of time. On top of that AnimMontages are used to blend weapon reloading and equipping.
The animations are from the Animation Starter Pack, freely available on the Unreal Engine marketplace.
Enemy AI wanders around the area during the night and moves towards noises made by the player. The AI is able to sense gun shots and footsteps and will attack the player on sight in a furious sprint.
The zombie has audio responses for many of the events including when sensing a player, idling, wandering, chasing, getting hit, dying, attacking etc. These audio files were kindly provided by @YorickCoster and can be used in your own projects too!
Dynamic Time of Day
The game features a dynamic time of day that is tied to the game mode. As during night time the zombies start spawning into the level and any existing zombies become more active and start wandering around the map. It supports networking with smooth interpolation on clients.
Known issue: The Skylight component does not support efficient runtime re-capture of the environment. To prevent a huge performance loss the lighting is not updated per frame, as a result the day/night isn't completely smooth the moment the sun sets.
Some of the objects in the world can be interacted with (Hotkey "E") These include the assault rifle, flashlight, cupcake and the bomb.
Consuming food restores hitpoints and energy while interacting with the bomb sets the fuze. Weapons can be added to the inventory.
Using the middle-mouse button, any physically simulated object can be picked up and moved around. Examples include the red barrier and the bomb actor. you can rotate the carried objects using the scroll-wheel and the 1 & 2 numeric keys. Left-clicking while carrying an object will throw it in the view direction. This is a neat trick to throw fuzed bombs are your enemy, or to throw food/equipment to your coop buddy.
For this series I've built a few maps to test out specific features. "DefaultMap" is used as the test bed for most newly introduced features.
A recently introduced map for the cooperative gamemode with a slight nudge to an open world.
Some may recognize it as "Shipment" from a well known shooter. It was used as a testing grounds for the AI sensing and the coop-gamemode.
Coop and Open World
The game was designed as a small 2-player coop survival game where players must survive as many nights as possible while using objects they find in the environment such as bombs, barriers and weapons. Additionally I've included a second gamemode stub you can use to build a more open ruleset for a DayZ/Rust like survival game.
2-Player Coop Survival
The gamemode features an accelerated day/night cycle, during the day players can collect items, equipment and setup defenses for the night to come. For the duration of the night zombies appear, any existing zombies become active and start moving around the map. Keep an eye out on your energy levels as low energy will hurt your health. If a player dies during the night, he will respawn at sunset as long as there is at least one other player still alive.
Players score points as they survive the night and by killing zombies. The game continues for as long as there is at least one player alive.
The open world gamemode is a stub that can be used to build your own open world ruleset. Unlike the coop mode, this mode is free-for-all (friendlyfire enabled) The mode lacks the scoring system, but supports the time of day and enemy spawns to get you started. Keep in mind that it's a basic setup and will require additional work depending on the design of your own game.
Taking this project beyond
This series is built primarily as a C++ learning resource. I hope you've learned a lot from the previous sections in this series and put that knowledge to use for your own project! If you wish to use this project as a base for your own game, you can!
Upgrade your game world
Don't forget to check out the amazing "A boy and his kite" demo, it's available on the Learn Tab in your Unreal Engine Launcher.
Have a look at the Open World Tools with many great open world rendering improvements introduced in 4.8!
I'd like to give a special thanks to everyone who helped out during the series. And especially Yorick Coster for providing free to use game audio! The audio files included with the project can be used in your own projects.
- Yorick Coster (@YorickCoster) for contributing many of the audio files
- Osman Tsjardiwal (@ozmant) for providing me with ContainerCity base map
- Everyone on the forums to helped with reporting bugs and feedback
- The contributors on GitHub
This section concludes the series, I hope you've learned many new C++ gameplay concepts and use this for your own game projects moving forward!
Project & Wiki by Tom Looman