17 Mar 2018

Block Runner (UE4)

A game I made for practice in Unreal Engine 4.

Block Runner

Block Runner is the title of a platformer game that I made in middle school. It was originally written in a language called DarkBASIC. The game featured a level editor that let players compose and share levels made of different types of blocks. It was inspired by - actually, it was a port of - blockaction.net (not mine).

The image above and most of this post concerns the newer version of the game in Unreal Engine 4. You can read about the original Block Runner in another post.


Video


Unreal Engine 4

While I was learning Unreal Engine, Block Runner was one of my first projects. I already knew what I was trying to create, so there wasn’t a lot of design work. A friend of mine helped me with some 3D assets and I copied most of the sprites from the original game directly. This left me with a very well-defined goal and nothing standing in my way except my complete lack of Unreal knowledge.

Working in an Engine

Unreal was the first game engine I ever worked with. Previously, every project I worked on was coded more or less from scratch, graphics and all. Coming from this background, game engines seemed pretty inconvenient at times. Sure, they do a lot of the work for you, but they take some of the control away from you (especially if you don’t yet know what you’re doing). I ran into a number of problems that I could not approach the way I normally would. Because of this, I had a lot of fun coming up with creative solutions and my experience with Unreal was more exciting than I thought it would be.


Physics

All of the physics for this game is handled by Unreal Engine’s physics system. I often had to fight with Unreal’s more realistic physics implementation to create more game-y 2D physics. What I mean by this is that realistic physics are not always ideal for games. Players want controls that feel good. To get the kind of tight, responsive controls players expect from a quality platformer, you need to allow certain actions that require unrealistic physics. Here are some examples of special physics from Block Runner:

Mid-air movement

The ability to move left or right in mid-air to adjust the aim on a jump. Normally, the player object is moved by applying a force to the character’s physics body until a certain velocity is reached. In mid-air, however, I wanted the player to have some control but not as much as they would on the ground. To accomplish this, I needed to track whether the character was standing on a floor. This was implemented as a state variable which is unset upon jumping or falling and reset when an invisible collider at the character’s feet touches a valid ground object.

One-way platforms

The ability to pass through platforms in one direction but not the other. Unreal may have some built in functionality for this, but if they did I wasn’t aware of it. My one way platforms are created using a collision box trigger which makes the platforms non-solid while the player is touching them. I place the trigger volume on the underside of the platform so the player can jump up from underneath and then land on the top.

Ice physics

The ability to move comfortably on otherwise frictionless ice. I wanted the character to maintain any velocity it had before stepping or falling onto ice. Howvwer, I also wanted the player to be able control the character a bit. Luckily, forces applied to the character for movement don’t require ground friction, but to make ice slippery and convincing, I still needed to modife movement controls when the character is on ice. Throughtout the game, the character controller keeps track of whether the character is standing on the ground, and which block/blocks are below the character.

Wall slides

The ability to grab onto and slide slowly down walls of most (but not all) block types. Similar to ground tracking, their are invisible collision volumes on the left and right side of the character. I keep track of whether the character is touching a wall-slidable material and if they are pressing left/right into it. When conditions are met, the player’s state is set to wall-sliding (right/left) and their falling speed is repeatedly dampened. I also enable a little spark emitter.

Wall jumps

The ability to wall-jump away from walls the character is sliding on. This verb was pretty easy to implement one I had regular jumping and wall sliding. If the character is currently wall sliding and the player presses the jump button or tries to move away from the wall they are on, then a wall-jump is performed. This simply applies an impulse force to the character at an angle away from the wall.

Each of these “verbs” required some inventive work-arounds to put them in Unreal. In the end I think there are still a number of problems with the character’s responsiveness and the tightness of the controls, but I now know a little bit about dealing with these issues that I didn’t know then.


Graphics

Using a game engine makes creating graphics for games a lot more fun than if you have to program them. I played with Unreal’s particle systems, post-processing effects, and sprite rendering with a very welcomed ease. Orignally, I made everything 2D, using the assets I had already created for the original game. Once things were working, however, I switched to 3D. My friend made me some simple texture-mapped block moddels and I made a cool-looking, minimalist background. The result is what you see in the video and rather I like it.


Code

I actually didn’t do any programming for this project. At least not what I’d normally call programming. The code for all blocks and the character was done using Unreal’s visual, node-based scripting. I could have used C++ just as well, but I was actually having a lot of fun with the node editor. Here are some “code” examples from the project:

Wall sliding:

Ice slipperiness

Full character controller overview