Skip to main content

Unreal Engine 4 Dev Update #5: HUD based Command UI, Grid based movement system & Dynamically Spawning Grids

Welcome back to the blog, it's time for another update. Starting with this post, I'll be posting only the details regarding the new development in the dev updates. I'll post tutorials for some of them as separate posts. I'm doing this since I don't have time to write the tutorials for each and every one of my updates. So I'll be making tutorials only for those topics which aren't available elsewhere. With that out of the way, let's get to this week's dev update. I'm already behind schedule by a few posts.

In my last update, I had written about how to implement keyboard input based camera rotation for Top Down games. You can find it here:

Unreal Engine 4 Dev Update #4: Camera Rotation for Top Down Games

Moving on to the updates, these are the main changes that I have made:
                       
HUD based Command UI
                                    
Following my last update, I worked on implementing a basic HUD based Command UI. Since I hadn't worked on HUD Blueprints before, I looked into the HUD based Blueprint examples available in the UE4 Marketplace. After tinkering around with Blueprints, I came up with a basic Command UI. Since I'm trying to work towards a Turn-Based shooter, I added two buttons that serve the basic purposes - Movement and Firing. The 'Move' button basically ask the player character to move to the location under mouse click, while the 'Fire' button fires a projectile in the direction of the mouse click. It's pretty basic stuff, you can see it in action in this video:
                                                                                                                    
    
Grid based movement system
   
Next up, I implemented a Grid based movement system. Initially my plan was to manually add box meshes around the level and then concentrate on the player movement separately. But since it was too much redundant work, I decided to spawn the meshes dynamically at level start. Well, not strictly dynamic since I hard coded the boundary of the playable area. Using the boundary data, I created an array by dividing the total game space grid by 100. For each of these 100x100 grids in game space, an element was added to the array. In order to store both X and Y coordinate data in the array, I used two 'For loops' while making the calculations. The vector data thus obtained was added to the array at level start, thus giving me a list of locations that the player can move to. As a temporary measure, simple box meshes are spawned along the grid at level start to depict the grid system. The data from the grid array is used every time the player character is issued a move command. Based on the click location and the array data, I was thus able to restrict the player movement to the grids. Here is a short video demonstrating the system:
                                                                                                 

Dynamically Spawning Localized Grids
                                    
After the UE4 update from v4.4 to v4.5, my level got a massive frame rate hit. With nearly 1600 grid meshes at level start, my system couldn't even run it at 10 fps. Hitting up the forums and UE4 Answer Hub didn't get me a satisfactory solution. As a result, I decided to move on to localized grids instead of an all-encompassing grid system. Instead of spawning the grids at level start, I switched to dynamically spawning localized grids based on player's mouse input. This helped reduce the number of grid meshes from 1600 meshes to just 9 meshes, and thus helped bring the frame rate back to speed. It also helped in keeping the game space clean. Now every time the player clicks on the floor, grids are spawned in the region corresponding to and surrounding the mouse click location. I'll leave you with a video for the same in action: 
  

Alright that's it for this update. If you're interested in seeing more of my work, feel free to check out my Youtube channel, as I generally upload my work over there before the weekly blog update.


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 4 Tutorial #4: Basic HUD Based Command UI for Top Down Turn Based Games

Hi, welcome back for the next tutorial. And in this tutorial, I'll be explaining how to create a basic Command UI for top down turn based games using HUD blueprints. By the time we reach the end of the tutorial, we'll have a Command UI with movement and fire action commands, and a player character that responds to the commands. Here's a screenshot showing the end product: 


Oh, and this tutorial is gonna be quite big, compared to earlier ones. So I advise everyone to go through the screenshots, before reading through. If it's clear, there's no need to read through the whole thing, partly because I've written this with a beginner audience target in mind. Ofcourse, if you have doubts, I hope they will be clarified in the written description. If not, feel free to ask me in the comments.
So let's get started. Again, I'll be starting with the top down template. First of all, we need to create a new HUD blueprint. If you're a beginner, you can find this by f…

Unreal Engine 4 Tutorial #3: Unit Selection Decals for RTS Games

Hi, welcome back for another UE4 Tutorial. This time, I'll be walking you through how to set up unit selection decals for RTS games. So the decals need to be visible, when a particular unit is selected, and set to hidden as soon as the unit is deselected. For this tutorial, I'm gonna start off from the Unreal Top Down Template.

First of all, I'll be changing the default controls a bit. Instead of using left mouse button to move the units, I'll be using right mouse button for character movement. I already have a decal texture, that I created in GIMP. If you don't have one, you could get my decal texture from the link below:
DropBox: Character Selection Decal Texture
So once you have the texture ready, next step is to set up your decal material. For creating a decal material, we need to set the 'Material Domain' in the details panel to 'Deferred Decal'. I'm also setting the blend mode to 'Emissive' in my case. Then we multiply the texture wit…