Sunday, January 31, 2016

Unreal Engine Tutorial: Create Circular Ring Material without Textures


Hi, welcome back for another tutorial. It's been quite a while since I put up a tutorial as I've been busy working on toolkits for the Marketplace. One of my earlier tutorials [link: Unit Selection Decals for RTS Games] had focused on how to create ring materials using textures, as well as using them to display unit selection decals for RTS games. However, a drawback associated with using textures was that it prevented the user from changing the inner & outer radius of the ring. And during prototyping stages of a product, it's far better to implement structures that can be changed easily from within the engine so that you don't have to create a new asset from an external package every time you need to test out a new idea. I've found this approach quite useful while working on my own products. Hence, this tutorial focuses on creating a ring material that can be adjusted both from within the material editor as well as dynamically at runtime.

Alright before we get started, I'm going to use the default Top Down Template that comes free with the Unreal Engine, as the top down view is a good example for showcasing the uses of a ring material. We're going to be creating a decal material here. So the first step is to create a new material from the content browser & adjust it's default properties from the detail panel. Under the 'Material' category of the details panel, set 'Material Domain' to 'Deferred Decal' & 'Decal Blend Node' to 'Emissive' as shown in the screenshot below.


Now right click within the material editor & create two 'RadialGradientExponential' nodes. This node is normally used to produce radial gradients, but we're just going to use them to create two circles. The gradient effect can be negated by increasing the density of both these gradients. For that, just create a new constant expression & set it's value to 100. Connect it to the 'Density' input of both the gradient nodes. Now with that taken care of, we need to specify the outer & inner radius of the ring material. Create two scalar parameters 'OuterRadius' & 'InnerRadius' with the values 0.5 & 0.4 respectively. Connect these two to the 'Radius' input of the gradient nodes. Now subtract the inner radius gradient node from the outer radius gradient node & connect this to the 'Opacity' parameter of the material.


We have thus implemented the core logic for the ring material. Now on to the emissivity & opacity to wrap it up. First, create a vector parameter named 'BaseColor' & a scalar parameter named 'Emissivity' with the default value of 2. Multiple both of them & then multiply it's output with the result of the subtract node we added for the gradients. Connect the result to the 'Emissive' parameter of the material & we have created a circular ring material.


This next step is not necessary, but I created two material instances using this material: one for the unit selection decal & the other for displaying attack range. 

Alright, now select the Top Down Character & add two 'Decal' components to it: a Unit Selection Decal & a Range Display Decal. Set the Z value of both to -98 cm & pitch value to -90 degrees. The pitch value is changed because the default orientation of the decal component spawns it in an invisible plane. Since the default dimensions are too small for our needs, we can scale up the Unit Selection & Range Display Decal to (1, 50, 50) & (1, 400, 400). As you may have noticed, we do not scale up the X value. This is because we don't want the decal to be drawn on surrounding objects. Setting it to one allows it to behave in such a way that it gets cut off by the obstacles in it's path instead of painting over them.


Now if you play in the editor, you should be able to see both the unit selection & range display decals display & move along with your character as shown in the screenshot below:


Alright, so that's it for this tutorial. I'll be continuing on with the Unreal Engine diaries series for concepts that do not require a whole tutorial. But I have some ideas for new tutorials as well & if possible, will try to upload them some time during this coming week. Until then, goodbye & have a great weekend. :)

Thursday, January 14, 2016

Top Down Stealth Toolkit for Unreal Engine Marketplace

The Top Down Stealth Toolkit is a pure blueprint framework that enables quick & easy creation of stealth games from a top down perspective. It is now available in the Unreal Engine Marketplace at: https://www.unrealengine.com/marketplace/top-down-stealth-toolkit


Features:
- Top Down Camera Perspective.
- Patrol Guards that can respond to multiple types of stimuli including the player character, incapacitated team mates, alarms, & other types of noises.
- Cameras, Motion Sensors, Laser Security Systems, & Turrets function as supporting entities to assist the Patrol Guards & provide additional layers of challenge to the player.

- Use Whistle, Gadgets, Suit Abilities, & Weapons to distract or disable AI Bots.

- Gadgets: Proximity ShockMine.

- Suit Abilities: EMP Blast.

- Weapons: Stun Gun, Hand Gun, & Silenced Hand Gun.

- Place Exit Point & collectible Gems across the level to drive the core gameplay.

- The Loadout Menu at level startup enables selection of Gadgets through player driven choices.

- A persistent Mission Stats system that provides High Score information at the end of a level.

- Dynamic Vision Arcs, Noise Pulse Emitters, Range Decals, & AI State Display Icons accurately portray information about the AI Perception Status to the player, thus providing the tools to make calculated decisions.

Technical Details:

- The Suit Abilities, Gadgets, Weapon Systems, & Stamina Management for the player character, & Dynamic Vision Arcs, Laser Tracking, & Patrol Waypoint systems for the AI Bots are handled through the use of custom components & interfaces. The component based design provides improved modularity & enables easy integration with different classes.

- Variables are categorized into 'User Defined' & 'Automatically Set' to facilitate identification of customizable parameters.

- The Vision Arc Optimizer actor provides performance boost by removing rendering calculations for Vision Arcs outside the screenspace.

- Blueprint function library employed to easily retrieve references to core gameplay actors from all blueprints.

- Event driven logic used predominantly over continuously ticking services for HUD updates.

- Ranged Patrol Guards & Turrets use Laser Tracking components to acquire & lock on to targets.

- The Game Mode handles initialization of all core gameplay actors from a single central location using a linear workflow design.

- The Player Controller acts as a conduit for all low level HUD update requests, while the Game Instace & HUD classes manage high level HUD changes.
- The Gadget Selection menu is populated dynamically based on information specified in the Gadget Data Array, thus eliminating the need for manual HUD changes when adding/removing gadgets.

Intended Platform: Windows

Optimized for: Unreal Engine v4.10 & v4.11


Preview Screenshots:





Preview Video: 



For more information, check out the official Unreal Engine forum thread: https://forums.unrealengine.com/showthread.php?97156-Top-Down-Stealth-Toolkit

Wednesday, January 6, 2016

Unreal Engine Diaries #11: Nav Mesh Configuration

[This episode of Unreal Engine Diaries focuses primarily on nav mesh configuration, nav areas & configuration of agent types.

Source: Unreal Engine 4 AI Support Twitch Broadcast with Mieszko: https://www.youtube.com/watch?v=7LaazCv4rB0]


1. The Recast NavMesh has a couple of attributes named 'CellSize' & 'CellHeight' under the 'Generation' section in it's details panel. Together they determine the resolution of the nav mesh & lowering these values can create more precise nav meshes. It could be especially useful when there are lot of holes in the nav mesh due to the surface properties of the terrain. However, lowering them also makes the nav mesh calculations more expensive.

2. If runtime nav mesh generation is enabled, it would be best to set the 'Tile Size' attribute of Recast NavMesh to the minimum viable amount.

3. The 'Min Region Area' parameter which can also be found under 'Generation' section of Recast NavMesh can be increased to get rid of small nav mesh islands that are isolated from the rest of the nav mesh regions.

4. When moving around objects that can influence the nav mesh with the runtime nav mesh generation enabled, it is far more efficient to use the actors as dynamic obstacles (with custom nav area settings) when compared to moving around actors in their default state. For static meshes this can be done from the static mesh editor as shown:



Just tick the 'Is Dynamic Obstacle?' checkbox & set the nav area type from the dropdown right above it. 

Alternatively, the same can be set up from the collision components in actor classes as shown below: [same procedure as mentioned in the static mesh editor workflow]



5. If you have tall characters in your game that are having issues with the nav mesh pathing, go to 'Navigation System' category under Project Settings. Add a new 'Supported Agents' & then try increasing the z value of 'Default Query Extent' of the new agent. 

On the other hand, in order to create separate nav mesh pathing for the bigger AI characters, add a new element to 'Supported agents' array & specify custom agent radius, query extent, agent height, etc. Build paths again to see a new nav mesh recast in the Scene Outliner tab. The 'Enable Drawing' parameter under Recast Navmesh can be ticked On to visualize the new nav mesh. It seems that the navigation system will automatically determine which agent type is suitable for the bot based on it's collision capsule size.