Guide: Real-Time Dynamic Cover System for UE4
Events
Subscribe:  iCal  |  Google Calendar
Las Vegas US   8, Jan — 12, Jan
Zürich CH   31, Jan — 4, Feb
Leamington Spa GB   31, Jan — 3, Feb
Bradford GB   6, Feb — 11, Feb
Bradford GB   7, Feb — 9, Feb
Latest comments
by Hannah Cuthbertson
3 hours ago

Informative post. Thanks for sharing this piece of content. If you are looking for MLM Software Company and want to discuss about your new MLM business startup. Feel free to contact us. - Neon MLM Software

by Rowlan
15 hours ago

If you go for Unity and Biomes, as you wrote in your article, please do support Vegetation Studio Pro. Your work is awesome, can't wait to see it on the store.

by Dara Burke
17 hours ago

Great breakdown of the process and optimization, thanks for sharing.

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

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

Source: horugame.com

Leave a Reply

Be the First to Comment!

avatar
wpDiscuz