A Survival Game in UE4 – Part 1

I’m currently working on a personal project on UE4, a quite big project of a Survival Game that helps me to improve my skills with UE4 mechanics. I never had to deal with problems like GUI, fully dynamic lights, networking, procedural generation or inventory systems so it’s an amazing experience in all those fields.

There was quite a bit of work involved since I started, but now the very basics are set up and I can move forward pretty quickly.

All of it is done in blueprints for now, it’s easier to tweak and go back & forth with different ideas. Oh, and everything is done in my free time alongside working at Dark Stork Studios!

 

Dynamic Light System


 

I’m using the latest feature from Unreal Engine 4 that got added in 4.5, Ray Traced Distance Field Shadowing.

Then comes a Timeline, handling multiple things in a real-time basis like the rotation and intensity of the sun (a movable directional light), and the shadow casting. On top of it comes a timer that fires every X seconds based on the Quality Settings of the client, updating the SkyLight Color and the SkySphere Sun Position. I mostly rewritten how the original BP_SkySphere was working, implementing my functions and keeping only the part that interact with the material.

Ray Traced Distance Field Shadowing still have a heavy cost, eating 10fps over a static light backing on my ol’ HD6850. I’m updating to a GTX970 pretty soon so I’ll be able to update my performance hit on this topic later on.

The result:

This slideshow requires JavaScript.

 

Perception System


 

I created a sort of Perception System, while Epic is working on their own. It’s casting a sphere in front of the camera on around 2 meters, in a specific Overlap Chanel. If it finds something “triggerable”, it allows the player to press F (Activate) or E (Equip) and send this event to the Character Blueprint.

 

Inventory System


 

The hardest part was the Inventory. Fortunately I’ll have our UI Designer helping me on the look on his free time, because right now it looks pretty “programmer art” and I’m not even a programmer.

It’s quite simple, but robust. It consists in 3 parts: A Loot Spawner, an Inventory Window and an Item Bar.

The Loot Spawner, can take any form or shape that the player can trigger with his Perception System and opens a “Loot Window” . It can also display different effects if you are the Instigator or just a Spectator of this event.

In green, a Spawner that got caught in the Perception System. It is activated, so it opened a Loot Window.
In green, a Spawner that got caught in the Perception System. It is activated, so it opened a Loot Window.

By clicking on any item in the Loot Window, it disappears and is sent to the inventory of the instigator.

On the bottom you can see a bar that will hold items usable with Quick Keys, like 1, 2, 3… and so on.

Weapons won’t be held in this bar, as a character will be able to hold only one at a time (…at least in the beginning).

The Inventory itself.
The Inventory itself.

The inventory itself opens with the TAB key and holds all the current items. When the player is clicking on any item, an event is sent to the item and it will react accordingly. Consumable will be consumed, Weapons and Equipment will be Equipped etc. All mechanics are handled per-items, which makes this system very versatile. Plus, the inventory can completely change it’s shape or size on-the-fly, and it won’t affect your objects inside of it.

The Drag & Drop mechanics to re-order or place in a chest is not yet implemented, I hope Epic will make a more reliable and user-friendly system anytime soon. Right now you can still have the inventory AND a Loot Window opened, and see the real-time change in your inventory.

 

Weapons Mechanics


Weapons are a crucial part of this project and I hope I made them well and won’t be stuck with a half-working system later in the process…

When equipping a weapon, it disappears from the inventory and appears in the hands of the character. There’s a UMG Widget representing the weapon, its name, magazine size and current bullets amount.

Weapon Equiped, with it's own UMG Widget on the side and it's name displayed.
Weapon Equiped, with it’s own UMG Widget on the side and it’s name displayed.

Right now my Weapons consists of two separate objects, one is an Item that takes place in the inventory and Loot Spawners, the other one holds all the mechanics of this weapon (accuracy, magazine size, damages, mesh, animations…).

Upon firing it casts a ray in front of the player and influenced by his camera central point (the crosshair). My raycast uses another channel and will display different effects if it hits a pawn or a simple environmental static mesh.

Weapon Firing a projectile, exploding on impact and spawning a decal normalized and rotated upon the impact angle.
Weapon Firing a projectile, exploding on impact and spawning a decal normalized and rotated upon the impact angle.

 

In one of my next posts I’ll detail more about the techniques and blueprints used in this project, let me know in the comments if you’d like a specific one to be covered first.

I’ll also explain my procedural building generation system in a near future. Stay nearby, I’ll keep you updated !