Sorting, trees, and Reborn

I haven’t updated this site in a little while – and I should do more regularly. I thought I’d get this ball rolling by writing something short about what I’ve been up to this week.

Sorting and trees

In the world of C++ and brushing up on my coding skills, I’ve decided that I should revisit the ideas behind different sorting algorithms, as well as different implementations of tree structures. Quite some time ago I did cover this in a university course, but it was long enough ago that I have forgotten the majority of it.

The reason I’ve been looking at this is:

  1. I am always worried I’m not implementing my code in a smart way and could improve it
  2. Sorting and trees seem to crop up frequently in code tests for jobs

Implementing this in C++ has also been a great way to look at the built in libraries and the functions they provide, as well as becoming even more familiar with iterators.

There was some inspiration when someone linked me to too. Such an excellent website

Everything I’ve added so far is here on my github.

Software development styles

Out of interest and curiosity, I’ve been doing a small amount of research into software development style/principles, like agile, or scrum.

These are terms that I’ve seen thrown around the place, and have wondered for a while what they actually refer to. Its been interesting reading the ideas behind these methodologies and what I think I would work well with. The agile-like ones all seem very appealing to me!

The PhD

The project continues. Work would be faster if I didn’t keep finding bugs in code significant enough to have to re-do days worth of analysis. Past-me is infuriatingly bad at spotting stupid mistakes, and the tests that I currently want to run take ~6 minutes each, and are repeated 1000 times.

DOTA2 Reborn

I’ve been playing around with the new editing tools for DOTA2 – they’re quite nifty. Hoping to design some alternate 3-lane map layouts, and I’ll make another post with some of my designs!


Creating an MMO-style controller VIII: Future Improvements

So we’ve completed our programming objectives! Is there anything left to cover? The overview and list of sections is in this post.

Our controller is good, but its by no means perfect. There are a few little quirks that need to be ironed out:

Strafing not so smoothly

Something a little strange happens when we go from strafing left to quickly strafing right. The character appears to flip direction very quickly.

A potential fix for this would require looking at our animation blend spaces, which would require having some specific animations for strafing.

Fortunately there are some game examples available from the Unreal Marketplace which have some assets to pinch! The First Person shooter has some assets, such as a 2D blend space for motion, that could be re-purposed for our use.

Statically rotating

When we rotate, the character does not move. It statically rotates around on the yaw axis. Its a bit strange looking.

To fix this requires an animation update, and perhaps another boolean flag to indicate that we are rotating. We’d then feed this into the state machine that blends motion in our character, so it could perform some kind of motion while rotating.

Right and mouse click together

In some MMO games, if you click and hold both the right and left mouse buttons, your character will begin moving forwards for as long as you hold these buttons down.

This sounds easy to implement, right? Well, in that case, I’ll leave this as an “exercise for the reader”

Anything else?

If you’ve noticed anything else about the controller that is odd, or want to suggest an improvement, feel free to leave a comment! I’d love to hear about any improvements that could be made to this work, since I’ll be using it in games I make.

Creating an MMO-style controller VII: Click and Drag Camera Control

Part seven in the development of our MMO-style controller. The original specification with contents and an overview can be found in this post. Quite a lot of posts now, isn’t it!?

Now we’re moving back to our final feature in the MMO-style controller, using the mouse to move our camera around, and control the character’s orientation. All those functions we wrote earlier are really going to help us here!

Left and right click actions

Firstly, we’re going to need to set up some logic with for the when the user presses the right and left click buttons on their mouse.

First we’ll need some functions to control interaction with the UI and game world:

Function ToggleUIControlOn

Function ToggleUIControlOn, enables interaction with a UI.

Function ToggleUIControlOff

Function ToggleUIControlOff

These two functions change how we interact with the game world. We’ll use these support the mouse drag and rotate feature. When toggled off, the mouse disappears and we cannot interact with the UI. We’ll also disable mouse related events for the game. If we set UI control back on again, we’ll keep the mouse to the game window, and re-enable the things that were turned off.

Now we can add these into the left click action event:

Left Click action

Left click action

When we press left click, we set a LeftMousePressed boolean to true, and we turn off the UI Control.

When left click is released again, we’ll re-enable UI control if right click is not also pressed. If RightMousePressed is true, we do nothing.

The final node in the released chain is a little bit of polish. Once we’ve done rotating the camera using left click and drag, the next time we move, we want the character to move in the direction the camera is facing. We do this by updating the rotation of MyPlayerController.

Hoe about the right click action event?

Right click action

Right click action

This almost the same as left click, but we don’t add that final function to the released sequence. The reason for this, is that right click and drag will update rotation anyway, so we don’t need to do this twice.

Camera rotation control

The vital and missing information left out from the initial upload!

There are two functions to create which are used to control the camera:





This will allow us to control the position of the camera.

Left click and drag camera

We’ve done a lot of the hard work for this earlier in setting up our blueprints. EDIT: Looks like I missed adding this information when I first uploaded. It is now included in the section above.

Left click and drag blueprint

Left click and drag blueprint

Since we have the axes Turn and LookUp already set up, it is a simple task to only make these events do something is LeftMousePressed is true.

If it is true – that is the player is holding left mouse down and moving the camera – we simply rotate the camera, using our two functions CameraTurn and CameraLookUp.

Almost too easy!

Right click and drag camera

What does holding right click and drag do? We rotate the camera and the player controller. Easy.

Right click and drag

Right click and drag

Very similar to left click, except we also need to RotateCharacterToCamera, and add pitch input to the player controller. What could be simpler!?

All our hard work earlier really paid off in this section. Those re-usable functions really are worth their weight in gold, and make the blueprints a lot more readable.

Creating an MMO-style controller VI: Orient Character to Movement Direction

Development of our MMO-style controller, part six! The original specification with contents and an overview can be found in this post.

This is going to be the most complicated part so far. This section of blueprints replaces the functionality we removed in an earlier post, but adds some custom controls that we need.

This code will be added to the MyCharacter blueprint event graph.

Continue reading

Creating an MMO-style controller V: Character Rotation

Part four in the development of our MMO-style controller. The original specification with contents and an overview can be found in this post.

We’ll be adding in the options to rotate the character and camera this time, using the A and D buttons. It’s the final basic input axis for controlling the character.

We want to rotate around the character and also have the character rotate as we do so, depending on which way we go.  There is one complication: as per our design, if the right-click mouse button is held down, we want to strafe with our character instead of rotating.

Continue reading

Creating an MMO-style controller IV: Character Movement

Continuing the development of our MMO-style controller. Contents and overview can be found in this post.

Time to make our character move! This section will focus on movement on the forward/backward axis, and the left/right strafing axis.

First things first: Deletions in the default blueprint!

If you open up the default MyCharacter (or ThirdPersonCharacter) and open up the Event Graph, you will see that it is already populated by various input controls. Make sure to delete everything inside the Movement Input and Mouse Input comment boxes. We wont be able to properly control the character and camera for now, but that will be quickly remedied.

We’re actually going to code our movement controls in MyPlayerController, so open that blueprint up to add the following functions.

Continue reading

Creating an MMO-style controller III: Camera zoom with the mouse wheel

So part three for this mini series, and the first actual section of coding! Camera Zoom! The overview and list of sections is in this post.

I wanted to start with something relatively simple, and start out with a small victory. The zoom functionality is quite simple, it allows us to get a better view of the level by zooming in and out, but keeping the camera focused on the player. Continue reading

Creating an MMO-style controller II: Blueprint settings, input actions and axes

We’re getting started in Unreal Editor now, for part two in the MMO -style controller mini-series. The overview and list of sections is in this post.

Start by creating a new project, use the Third Person Template, in the blueprint section. You could do this in C++, and I will do in the future.

Create a new project using the Third Person Blueprint template

Create a new project using the Third Person Blueprint template

We’ll change some things in the blueprints that you are provided with by default, so we can add the features we want our controller to have.

Continue reading

Creating an MMO-style controller I: Overview

MMO Controller

I mentioned in this post the motivations for creating an MMO-style control system for a third-person game. But what is an MMO-style control system, exactly?

From extensive research (read: I played a bunch of games), I’ve selected a few criteria for a generalised MMO controller:

Movement of the character along the ground:

  • Move forward and backwards using W and S
  • Rotate the character and camera with A and D
  • Strafe left and right with Q and E
  • Moving backwards is much slower than forwards

Controlling the camera is also linked to movement:

  • Mouse cursor is visible, can interact with UI
  • Holding mouse left-click and dragging the cursor around rotates the camera (but not the character’s direction of movement)
  • Holding mouse right-click and dragging rotates the camera and the character’s direction of movement
  • While right click is held, rotate (A and D) will make the character strafe
  • Mouse wheel is used to zoom in and out

Other considerations:

  • The character needs to orient itself smoothly to the direction of movement
  • When moving backwards, the character orientates to the opposite direction to movement – that is, when walking backwards, the character’s back faces the camera

Creating an MMO-style controller in Unreal Engine

For the last little while I’ve been teaching myself Unreal Engine. Recently, Epic Games made it completely free to use for anyone, which I think is an absolutely amazing idea. It could possibly be fundamental for pushing video games even further by getting future developers hooked.

Since I’m learning from the ground up, I wanted to create an MMO-style control system, using the blueprint system, based on the third person template available. Control systems are pretty fundamental in video games, and I have some very specific memories of completely giving up on well known titles because of bad input design.

Continue reading