Developer Journals : Box Traces

Developer Journal

As of the 19th of April, I’ve used this week to further refine my top down Unreal prototype.

As of recently, I’ve decided to create sliding blocks for my game. These blocks are moved into any direction if the player collides with them at a certain face, it will then accurately move it along a grid using BoxTraceByChannel.

BoxTraceByChannel is a collision function that uses traces for its detection, the trace can detect any objects blocking the way and thus can provide a result.

“Sweeps a box along the given line and returns the first blocking hit encountered. This trace finds the objects that RESPONDS to the given TraceChannel”, 2021

An example of how I used this is that for the sliding block, traces are used to check each square in front of the blocks before moving it. If there is nothing blocking the trace, then the block is permitted to move – This is shown by the red colour as seen in Figure 1.

Figure 1

If the traces detect any solid objects such as walls or items, then it will display as green in front of the cube and not allow it to move as seen on Figure 2.

Figure 2

Here is an example of how it should work in game as shown in Figure 3, the sliding block should slide alongside the floor and stop if there is a wall in front of it. There is a trail of red traces alongside some green ones against a couple of walls, this is the collision at work.

Figure 3

To make this work, I gave the sliding block two collision boxes inside of it in Figure 4. As the player has a small pointed bit on its front, it will be able to activate one of these if it faces towards the cube.

Figure 4

If the player were to overlap onto one of these box collisions, it would cast to the player to see if they were pushing the block, and then get their X or Y location to see which side the player was colliding from – this is what can make the box go into different directions. (Figure 5)

Figure 5

Once collided, a box trace will spawn in front of the direction the block will be sliding to check and see if there are any collisions in the way. This is done by just spawning a trace 50 units ahead of the object and snapping it to a certain location with a custom function to make it more accurate. (Figure 6)

Figure 6

If the traces don’t collide with anything, then a Move Component function is used to simply move the sliding block ahead. (Figure 7)

Figure 7

This was a fairly hard thing to do, but with some help and research I was able to get it working.

From this I managed to learn how to use traces for collisions, which can prove to be useful if you’re looking to make objects that move accurately without having to depend on physics.

Figure 8

I also briefly learnt how to use custom functions such as the one to help me with object snapping shown in Figure 8, this would calculate a grid size and offset to snap an object to.

Bibliography 2021. BoxTraceByChannel. [online] Available at: [Accessed 30 April 2021].


Developer Journal : Unreal Game

Developer Journal

As of the 12th of April, I used this week to make a start on my top down Unreal prototype.

So far, I’ve worked on actors and characters using the blueprint system. As well as trying out making my own textures and materials for the game. These are all in one level so far, which will serve as the testing grounds for any future features I might be able to add (See Figure 1).

Figure 1, Self-Collection

First off, I will describe how I managed to create a playable character. For this I needed to use a PlayerInput object to be able to set some keyboard inputs the player could use to control their character.

“The PlayerInput Object is responsible for converting input from the player into data that Actors (like PlayerControllers or Pawns) can understand and make use of.”, 2021

In order to create a playable character, it was important for me to set some Input Mappings for the player. This would allow me to set certain mappings within the game with keys connected to them (See Figure 2).

Figure 2, Self-Collection

There are multiple mappings you can assign keys to, these being Action Mappings and Axis Mappings. As my game doesn’t have any necessary actions yet, I’ve just used Axis Mappings – note that I have also set some axis scales to minus values.

Action Mappings are a discrete button or key press bounded to an event-driven behaviour, the idea for this is that it would usually be assigned to a single action typically that required a single press of a button.

“The end effect is that pressing (and/or releasing) a key, mouse button, or keypad button directly triggers some game behavior.”, 2021

An example of how an Action Mapping would be used is that it could be for actions as simple as jumping, couching or attacking – these are typically events in games that only require a single press.

Axis Mappings are bound to more continuous game behaviours, the advantages of this is that it can allow for smooth transitions in movement as opposed to more discrete game events.

“The inputs mapped in AxisMappings are continuously polled, even if they are just reporting that their input value is currently zero.”, 2021

Some good examples for Axis Mappings would be general movement keys, like “WASD” controls. As these mappings are continuous, it would be preferable to hold these keys down for movement instead of constantly needing to input them.

Using blueprints, I connected set mappings to add movement to the player. The set world direction values will then be scaled by the axis scales I’ve connected to them (See Figure 3).

Figure 3, Self-Collection

For instance a regular W input will move the character forwards by X+1.0 , but an S input will move them by X-1.0 as it has a negative scale.

I will now mention briefly as to how I managed to import some custom textures I’ve made myself, importing textures is as easy as dragging and dropping a file into a folder.

Figure 4, Self-Collection

As I’ll be using pixelated textures, I need to set their texture group to “2D Pixels” within the Level of Detail tab in order for them to display properly.

Materials work similarly to how actors and characters are made, as they also require blueprinting (See Figure 5).

Figure 5, Self-Collection

As I don’t want the material of this texture to be too shiny, I’ve decided to increase the Roughness Input to 1 – What this does is control how rough or smooth a material’s surface is.

“A Roughness of 0 (smooth) results in a mirror reflection and roughness of 1 (rough) results in a diffuse (or matte) surface.”, 2021

As my texture is pixelated, I wouldn’t want it to look too reflective or shiny. However, if I were using a different texture that was meant to be reflective and smooth I could increase the values if I wanted – this may depend on what I can add into the game.

Bibliography 2021. Input. [online] Available at: [Accessed 19 April 2021]. 2021. Material Inputs. [online] Available at: [Accessed 19 April 2021].