Guide: Real-Time Dynamic Cover System for UE4
Subscribe:  iCal  |  Google Calendar
7, Mar — 12, Jun
San Francisco US   19, Mar — 24, Mar
Anaheim US   23, Mar — 26, Mar
San Jose US   26, Mar — 30, Mar
Washington US   30, Mar — 2, Apr
Latest comments

Well, small/medium intuos pro is way cheaper that iPad Pro + pencil... just saying... And it works better with ZBrush...

by some guy
17 hours ago

It might ultimately be proof of concept now, but the point of showing a low-count bounce raytracing that still looks decent especially after denoising gives us a nice roadmap on the future. Maybe given time, we will move to this as the new standard or at least a probable alternate to baked lighting.

by Nathan Ayotte
17 hours ago

Fuck you I'm stuck in some bullshit game some dickhead thought would be exciting.

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!