Skip to main content

Unreal Engine 4 Dev Update #7: RTS Camera System for Top Down Turn-Based Games

In my previous dev updates, I had talked about how I implemented a grid based movement system in the Top Down template. Now that we got that out of the way, I decided to tackle the issue with the default camera system in the Top Down template. Since I needed the camera to smoothly move to focus on the active character, it was kind of troublesome to use the default cameras as they were each attached to their corresponding characters. So I got rid of them. And now I have a new RTS style camera in place of it. Now this allows me to smoothly move the focus between the cameras depending on the game state. I'll just give a brief overview of the features that I've implemented.

First of all, I created a separate blueprint for the new camera. At the most basic level, it needs to move freely anywhere along the map. So I mapped the WASD keys to move the camera along the forward/backward and lateral directions. I'll probably add mouse based movement as well in the near future. All the features that I had implemented in my previous camera were directly added to this well. This included both keyboard based smooth zooming capabilities as well as keyboard based camera rotation. I had included tutorials for the same in a few of my earlier posts. You can find them here:




Anyways, this time around I decided to add mouse based zoom and rotation as well. As suggested by one of the members in the Unreal Engine community, I have used an interp node to add a mouse wheel based smooth zoom functionality. Alongside, I've mapped the middle mouse button drag to camera rotation. So with the exception of mouse based movement, I now have a camera that can move around the map freely. Here's a video demonstrating it:
                                        
        
As mentioned earlier, one of the problems that I faced with the earlier camera system was the difficulty with having the camera move smoothly towards the active character. So obviously, that was the next thing to tackle before moving on. The functionality for moving towards the newly selected actor was already implemented, but moving forward in that direction didn't serve my purpose well. I also had to take in to account, the fact that the camera needs to focus on the A.I. character as well, when I click on the end turn. So I rewrote the functionality to automatically move the camera between the characters. Again I use the interp node and player/A.I. movement status tests, to have the camera smoothly flow in to focus on the player. You can see it in action in the following video:
         
       
[Note: My PC is not very powerful. The stuttering issues during certain animations are a result of using the screen recording software alongside the editor and not the animation itself]
      
In this video, I've only shown the camera switching towards the active player character and not the A.I. since I was doing some work on the 'End Turn' feature. Now that I've implemented a basic end turn functionality, I'm happy to say that the camera movement smoothly switches it's focus on to the A.I., when it makes an action. So that's it for now. If you're interested in seeing more of my work, feel free to check out my Youtube channel:
        
Stormrage256' Youtube Channel
                              
In a day or two, I'll be uploading a new video with weapons and firing animations for the characters. Here are a few WIP screenshots until then:





Popular posts from this blog

Unreal Engine 4 Tutorial: Smooth Zoom using Mouse Wheel for Top Down Template

Well, I had already written a tutorial for implementing Smooth Zoom functionality for Top Down Template. But it was based on keyboard inputs. Since most Top Down PC games use mouse wheel for zoom, I decided to make a tutorial for the same. The core logic here is the same as the one implemented by Ryan Jon for the custom camera in his RTS Community Project. If anyone's interested, they can get the code for the RTS Community Project here:

UE4 RTS Community Project

Anyways, he has replaced the default camera for the characters with a general camera since that's more ideal for developing an RTS game. Since a basic Top Down game with a single playable character does not need a separate custom camera, I decided to implement the same functionality for the default player camera in UE4's Top Down Template. So let's get down to it.

First of all we need to make a custom curve from the content browser. We will be using this curve to define the smooth camera movement while zooming …

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 …

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 i…