# How would I go about making a character dash to where he is looking at in an FPS?

Attention Topic was automatically imported from the old Question2Answer platform.
Asked By Moot Point

I’m currently working on an FPS using Godot 3D based on this tutorial series and wanted to know how to make my character dash forward, backwards and to the sides, all based on where he is currently aiming. I’m kinda new to the engine so code examples would be really appreciated.

1 Like

I think there are 2 challenges for this mechanic:

1. Getting the direction to dash based on aim & user input
2. Adding some large impulse to the character so that they move in that direction

I assume that your player already has these two variables: a Vector3 for velocity and a Camera that references the Player’s camera. To get the direction, you will need the basis from the Camera’s global transform.

``````#Get the rotation of the head
var aim = camera.get_global_transform().basis;
``````

“aim” has three variables named x, y, and z. These are all Vectors that point up, sideways, and forwards relative to the camera’s transform. You can multiply these Vectors with another variable that represents the impulse you want to apply when the player dashes.

``````var dash_direction = Vector3();
dash_direction += aim.z * Vinput; #Vertical input (ranges from 1 to -1)
dash_direction += aim.x * Hinput; #Horizontal input (ranges from 1 to -1)
dash_direction = dash_direction.normalized();
var dash_vector = dash_direction * dash_speed;
``````

``````velocity += dash_vector;