How would you go about coding a Katana Zero style dash, a dash towards you mouse

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Sininenblue

I’m trying to make a platformer that has a dash. This dash would go towards your mouse every time you left-click but I’m having trouble with it.
I don’t have much (or any really) experience with Godot and Coding in general so something simple and janky would already be great.

Currently, I have something like this

dash_direction = get_global_mouse_position() - position
if Input.is_action_just_pressed("ui_mouse"):
	motion = dash_direction.normalized() * dash_speed

motion = move_and_slide(motion, Vector2.UP)

but the problem is that whenever I left click it does a weird L type motion and I don’t understand why

it does a weird L type motion and I don’t understand why

Do you apply any gravity to your Character? What is the value of dash_speed? When is this code called? physics_process? process? _input? _unhandled_input?

I cannot reproduce your issue.

njamster | 2020-03-23 17:47