Guide: Real-Time Dynamic Cover System for UE4
Subscribe:  iCal  |  Google Calendar
Birmingham GB   20, Sep — 24, Sep
Chiba JP   20, Sep — 24, Sep
Ohio US   21, Sep — 24, Sep
Los Angeles US   27, Sep — 1, Oct
Latest comments
by Zac
8 hours ago

Really cool in VR, but I wish the camera would be locked to the cart, so that it felt like I was sitting in it. Now when the cart moves, the head does not follow so it feels like I'm just floating with no contact with the cart.

9 hours ago

this is very inspirational. I love the look and feel of your environment

by TrickBox
19 hours ago

Nice ad Amazon but can we please at least have some cool behind the scene screenshot and informations instead of the regular Media tab of the official website ?

Guide: Real-Time Dynamic Cover System for UE4
13 March, 2018

Glass Beaver Studios has shared an amazing article on setting up a real-time cover system for games in Unreal Engine. The task might seem challenging, but it appears that you just need a couple of simple techniques to build the whole thing. You could use the tricks described in the breakdown for a next-generation RTS, a first-person shooter or anything else. 

Here is a small piece of guide to give you an idea:

When designing a cover system, the three most important challenges you will face are as follows:

  • Data generation
  • Data persistence
  • Data usage

Since this article focuses on creating a real-time dynamic cover system where cover may become available or disappear completely at run-time, it is essential to apply an optimized approach to all three.
I cover two data generation methods: navmesh edge-walking and 3D object scanning.

D:\OneDrive\Horu\Write-ups\Cover System\Article Assets\3D_Grid_Around_Object.jpg

3D object scanning

Navmesh edge-walking

If your cover data is generated synchronously, it causes a noticeable hitch in your game’s performance, resulting in lags in gameplay. I demonstrate how to make use of the Unreal Engine’s excellent multi-threaded APIs to parallelize cover data generation, taking advantage of multi-core processing typically found in modern-day gaming hardware.

Similarly, if access to cover data is too sluggish, your game slows down by a considerable amount,  consuming large amounts of CPU and/or GPU cycles on cover queries. To avoid this, it is best to use a data structure that was meant for real-time concurrent lookup of spatial data: the octree. Using octrees appropriately also allows storing custom cover data, e.g. cover material (stone vs. hay), height, health, etc. with quick and efficient access.

Data usage optimizations – for when your units are actively deciding which cover point to use in real-time – minimize the number of raycasts and ensure the availability of spatial lookup facilities (octree) as well as support for direct fetch requests (arrays or maps).

In order to project how a unit may step out of cover to open fire, it is necessary to map out its peeking or leaning capabilities. A tank can’t peek out of cover – a foot soldier can. The best way I’ve found to accomplish this without using too many raycasts is to define “leaning offsets” on units. These are just simple floats that get added to the unit’s location upon hit-testing from cover.

The final feature is real-time dynamic updates – whenever a new object is spawned in the game, we generate cover points around (and inside) it using Unreal’s event system via delegates. This ensures that we’re not wasting resources on Tick, which can slow the game down significantly if care isn’t taken. We hook into Recast’s navmesh tile update events and update cover points in the corresponding tiles only when necessary.

Despite all the techno-speak, it’s actually wonderfully simple: a few trivial for-loops and a couple of missing pages from the UE4 documentation. So let’s get cracking!

Glass Beaver Studios

You can find the full breakdown here.

The team has also shared the demo project file for you to better understand the principles described in the tutorial. 

Download The Demo Project


Leave a Reply

Be the First to Comment!