Unity Dash



In this tutorial you will learn how to make a dash in unity 3d, we will also look at how you can make a unity 2d dash movement effect. We will look at how a air dash can work and the c# dash script which will make our object or player dash in our game.

  1. The Unity Dash is part application launcher, part file search, and part search engine. It lets you find and open locally installed applications and search through your files and folders from one unified window via the Home scope. It’s interesting how the Dash evolved over the years, debuting the version you’re most familiar with back in 2012.
  2. Web::Dash is a Web application version of Unity Dash. Unity Dash is a powerful searching tool integrated in Unity desktop environment, which is employed by Ubuntu Linux. Web::Dash acts like Unity Dash without the need of the whole Unity infrastructure.

Consider donating to help me keep this channel and website alive: 💖Support me on Patreon: https://www.patreon.com/the.

To start off create a new 2d unity project. We will be looking at doing this in 2d first. So go ahead and open up unity hub and create a new project called unity 2d dash.

You should now have a blank project like this.

Unity

How 2d dash works in unity

So in order to perform a dash we need some instantaneous velocity applied to an object or our player. The way in which we can do this is by attaching a body to our player or game object and applying a force to it. Some things we need to take into account however is that we need to allow for a duration at which the dash will be allowed. So when writing our c# dash script we will need to have a delay timer. We also may want some configurable properties so we can modify how our dash behaves. We may need to consider adding some effects as well to our dash so that it doesn’t look too choppy or dull.

Unity 3d Dash Movement

So to start off we need a player. In our case we will use basic sprites provided by unity like squares. We also need a basic background so we can see the dash. In the next section we will start setting up our project. Then after that we will look at a script for our dash movement.

Setting up our unity dash project

Start by creating a unity square sprite. Go over to the assets and right click, goto create, sprites and click on square.

Rename the square to player.

We now need to add a kinematic body to our player. So to do this drag your player sprite into your hierarchy.

In your inspector with your player selected start by adding some new components. Add a box collider 2d and a rigid body 2d.

Hit play to see what happens. Our player sprite might now fall due to gravity. We want to restrict that.

You want to change your rigid body 2d to kinematic.

We now need to come up with a basic script to just get our player to move. Then we will add onto the script to allow our dash effect.

Dash c# script

In assets right click and create a new c# script. Call it dash move like this.

Let’s attach our script. Click on your player object in the hierarchy and drag the dash move c# script into your components like below.

Go ahead open up the dash move c# script in visual studio.

Let’s start off with basic movement. Let’s implement this using the new unity input system.

Unity dashing

We start off with this basic c# script to allow our player to move. We also added a variable for dashspeed. Which will allow us to control our dash speed. Let’s in the next version of our script adapt this basic script to control dashing.

Explaining the dash move script

Let me explain how this works. First we declare a c# enum, which will store our different directions. This will make our code a little easier to read. So in the enum we declare up,down,left and right. As well as no direction as when we stop our player from moving, there is no initial direction it will move in. We then declare a few variables, like dashDuration which is how long we will be dashing for.

Dash speed is the speed or velocity at which the dash will be performed. We declare a dashTimer which will keep time of whether we have exceeded our duration or not. Next we make sure we initialize our direction to NoDirection since we haven’t used the keyboard input as of yet. In our update method we look for input for the left, right, up and down arrow keys. For reach one we set our dash direction.

After that we check if we have a direction, if we do then we can kick off our timer to start our dash. We first check if our dashTimer has exceeded our duration, so we can stop our player from moving, reset our timer back to zero and reset our direction back to no direction. Otherwise if our timer is still running add a velocity in the direction we are dashing multiplied by our dashSpeed.

Now go ahead and add this script to your player and use the following settings in the inspector.

This is all good and well but let’s see how we can do this in 3d.

Unity 3d dash movement

We can actually use this very same script in 3d, let’s go ahead and create a new 3d scene. The easiest way to do this is to use your current unity project. Click on this 2D button.

Then let’s create ourselves a cube for a player. In your hierarchy right click. Go down to 3d object and click cube.

You should now have something like this.

We also need to change our camera settings.

Click on your main camera and change your settings to be perspective.

Because this is a 3d scene we need to introduce some light. So let’s add a directional light. Right click in your hierarchy and add a directional light.

You can go ahead now and delete your old player so it doesn’t interfere in our scene.

Adding components to our new 3d player

Add a rigidbody component and use these settings for our new cube player.

We can now drag our script onto our player. Use these settings.

Unity dashed line

You will now notice that nothing works. Well we need to modify our script. To make it work with 3d first thing we need to do is change all the Rigidbody2d to Rigidbody. All the vector2 to vector3. Here is the new script.

As you can see it’s not a major difference between the 3d and 2d version of the script. So now you have a basic overview of a unity 2d dash and unity 3d dash which you can use in your projects.

Frequently asked questions

How to make a dash in unity 3d?

To create a dash in unity 3d you can use the same concepts as you would in 2d, but change to 3d space. By converting from 2d rigidbody to rigidbody and vector2 to to vector3.

How do I make my unity dash effect look better?

You can use particle systems which play with every dash move, to give the effect of kicking up dust, leaving a cloud of dust.

Final words

If you liked this tutorial please consider supporting my youtube channel over here: https://www.youtube.com/channel/UC1i4hf14VYxV14h6MsPX0Yw

Also want to say thank you to Blackthornprod which inspired this tutorial with his work on dash moves in unity as well.

If you want to check out some other tutorials here are a few links to some of my other tutorials:

Running Ubuntu on an old laptop? Well, you may found that the Dash for searching files and installed applications is a little slow and heavy.

Here I’m going to show you how to speed up the Dash by disabling unwanted search results and doing a little tweak on graphics settings.

1. Disable undesired search results.

First, you may install Dconf Editor from Ubuntu Software Center.

Once installed, open dconf-Editor and then navigate to com > canonical > unity > dash. In the Scopes line remove the scopes you don’t use. I only use the Dash for searching installed applications, so it ended up looking like this:

[‘home.scope’, ‘applications.scope’]

Also in dconf-Editor window, navigate to com > canonical > unity > lenses. Remove unwanted values in always search, home-lens-default-view, home-lens-priority, and set remote-content-search to ‘none’. In my case it looks like:

Now open System Settings > Security & Privacy, you may:

  • disable recording and clear cache under File & Applications tab.
  • disable Amazon searching results under Search tab.

2. Reduce Graphic effects

After previous settings, your Unity Dash should be faster than before. If that is not enough, do below steps to reduce graphic effects on the Dash.

1. Search for and install compizconfig-settings-manager from Ubuntu Software Center.

2. Once installed, search for CCSM and launch it from the Dash. When it opens, find out Ubuntu Unity Plugin icon and click to go to its setting page.

Disable Dash blur effect by setting its value to no blur:

3. (Optional since below setting affects the whole system) In CCSM main window, click to go to OpenGL settings page and set value of Texture Filter to Fast.

Unity Dash Button

Log out and back in. Enjoy!