top of page
Search

Creating a Dash Mechanic

  • Abbie Hipwell
  • Apr 27, 2022
  • 4 min read

Updated: Jun 15, 2022


The dash mechanic has probably taken the longest to code so far; I initially started this back in February and coded a very simple dash which worked by increasing the players speed for a set amount of time. This was extremely similar to the sprint, however the speed would be set to a much higher value, with the dash lasting less time. I was confused on how to create the dash so settled with this while I worked on other things, however feedback from the playtest, such as the dash being too slow and barely noticeable, made me realise that I needed to add a lot more to create a dash which is more 'rapid' and engages the player. This is something that would help the game feel more energetic and competitive.


I looked into different games which feature dashing, particularly the dashing special ability which the character Genji has from Overwatch. This mechanic from Overwatch is well-recognised by its players, so could be well-received if we implemented it into our game.


I looked into a lot of tutorials, especially regarding timelines in Unreal, and began creating a more finalised version of the mechanic ...


I first began creating a timeline, using distance and time; time being along the bottom and distance being along the side. I had looked at some tutorials on these, as they were helpful in creating a dash which is more 'natural' looking. For example, rather than the player dashing at a sudden, consistent speed, the player would gradually speed up and reach a plateau in the dash. This makes the mechanic look a lot more smooth and natural.


I then made a function to dash to the right (we only want the player to dash left or right).

I created a float variable named Dash Distance and set this to 1500.

The function below takes the players right vector and multiplies this and the float Dash Distance together (this float gets converted into a vector). he result of this is then added onto the players original location, which is returned to the function as Dash Destination



The same function can be applied to dashing left, except the players right vector is multiplied by -1, this flips the vector to the left (as there is no left vector node in Unreal.



The blueprint below shows how the dash works, this is stored in ThirdPersonBP, I will break this down into stages and explain each section ...









Before starting the dash, the blueprint will check which direction the player wants to dash in. This stops them from being able to dash diagonally.








There is also a branch which checks whether the player is jumping and if the dash cooldown is active, if these are both false the player can dash.



Depending on which direction the player wants to dash in, either the left or right dash function will be ran, which returns the value Dash Destination and sets the variable B Vector to this. Dash is also set to True.


Depending on which direction the player wants to dash in, either the left or right dash function will be activated. This function will then return the vector variable Dash Destination, this is then stored in a vector variable called B Vector.



The vector variable Start Location is set using the Get Actor Location node, this is then input into the Dash Timeline which I created previously. This will determine where the players dash is starting from. The Dash Timeline then outputs the Dash value. This value alongside the players Start Location and the B Vector are input into a Lerp Vector node (linear interpolation). This node will interpolate between the values at A and B (Start Location and Dash Destination), based on the value of the alpha, if the alpha is set to 0, 100% of A will be used, if the alpha is set to 1, 100% of B will be used.


This means that the players movement between the start location and their final location will be gradual, the player will speed up at the start and slow down at the end. The players location is then set.


During this stage of development the dash was essentially working, however I had one issue with the player being able to dash through objects - and worst of all the centre barrier. This was happening as the dash changes the location of the player, without the player actually moving - therefore collisions are ignored. On the Set Actor Location node I was able to tick the Boolean Sweep and set this to True. Sweep will work by checking for collisions between the current location and the intended location. Therefore, if a player now tries to dash to the right whilst there is an object in the way, they will be stopped.



After this is complete, Dash? will be set to False, Is Dash Cooldown Active? is set to True, and there is a delay of 1.5, meaning the player cannot dash for this time. Once this is complete it is set to False so the player can dash again.



After adding this mechanic in, the gameplay of Battle Bay is already feeling a lot more fast-paced, and resembles real-life dodgeball - the dash will hopefully have much better feedback in the next playtest.

 
 
 

Comentarios


bottom of page