# Dash towards the mouse with vertical force.

Attention Topic was automatically imported from the old Question2Answer platform.

I can dash to the four directions relative to the camera, but only horizontally and can’t quite get the verticality right. I want to be able to dash upwards or downwards at an angle.

This is the code for the dash right now:

``````velocity = dash_direction * DASH_SPEED
dash_direction = dash_direction.normalized()
velocity = velocity.rotated(Vector3(0,1,0), rotation.y)
velocity = move_and_slide(velocity, Vector3.UP)
``````

I think we will need more code. Can you post the whole script maybe? specifically we will need to see where dash_direction is defined.

Millard | 2021-04-05 18:13

`dash_direction` is not specified and `rotated` is adding rotation. Do you have a working code example?

clemens.tolboom | 2021-04-05 18:17

If this is a platformer / side-view situation, the problem might be that gravity is messing up with your vertical speed so the dashes don’t feel right. Try disabling / counteracting the effect of gravity while you are dashing.

mirageowl | 2021-04-05 18:34

It’s a 3D FPS game. This is how the dash function gets it’s direction

``````	DASH:
dash_direction = direction
if direction == Vector3.ZERO:
``````

This is what defines direction

``````direction = Vector3()
direction += (int(s) - int(w)) * head_basis.z
direction += (int(d) - int(a)) * head_basis.x
``````

I’m having trouble on where to apply an angle and force to said angle.

Moot Point | 2021-04-07 10:46

Copy pasting here from another comment
It’s a 3D FPS game. This is how the dash function gets it’s direction

``````	DASH:
dash_direction = direction
if direction == Vector3.ZERO:
``````

This is what defines direction

``````direction = Vector3()
direction += (int(s) - int(w)) * head_basis.z
direction += (int(d) - int(a)) * head_basis.x
``````

I’m having trouble on where to apply an angle and force to said angle.

Moot Point | 2021-04-07 10:48

It’s better to add code to the question to get the whole picture. And maybe empty one of your comments And I miss the mouse code too.

clemens.tolboom | 2021-04-07 13:30

Ah, sorry, here it is.

``````func _input(event):
if event is InputEventMouseMotion: