|
|
|
 |
Reply From: |
SQBX |
In your _process
or _physics_process
function (Wherever you are setting the velocity), use an if-statement prior to setting the velocity to check if the player is not currently dashing.
if not dashing:
velocity = #Whatever you are setting velocity to
If you are changing velocity in multiple lines, put all of them within the if statement.
IMPORTANT: Don’t put your move_and_slide(velocity)
method inside the if statement or the player will not move when they are dashing.
Hey i moved all my velocities over to the end statement and applied move and slide after the if statements but the dash is still wonky, it is dashing but it is an instantanious teleport, and i have no clue why, but the distance is huge, and seemingly completely disconnected from what my dash speed is. im honestly stumped but maybe it has ot do with how im getting mouse coordinates.
how im getting mouse co ordinates in the get input function which is called in the physics_process, the specific mouse co ordinate call is below.
Thanks for the help!
#dash wip
if Input.is_action_just_pressed("dash"):
mouse_direction = get_local_mouse_position().normalized()
dash()
#dash
func dash():
if dash_pressed == 0:
dashing = true
$AnimatedSprite.play("dash up")
dash_pressed = 1
$DashTimer.start()
#dash timers
func _on_DashTimer_timeout():
$AnimatedSprite.play("idle")
dashing = false
$DashTimer/DashCooldown.start()
func _on_DashCooldown_timeout():
dash_pressed = 0
func _physics_process(delta):
get_input()
if dashing == false:
velocity = move_speed * velocity
else:
velocity = dash_speed * Vector2(mouse_direction.normalized())
velocity = move_and_slide(velocity)
consumetur | 2023-01-03 00:58
Change this line
velocity = dash_speed * Vector2(mouse_direction.normalized())
To
velocity = dash_speed * mouse_direction.normalized()
Because normalized()
already returns a Vector2
. If that still doesn’t work, dash_speed
may be set to too high of a value. Try setting it to a really low value and increase it as needed.
Tell me if you need any more help
I took out the secondary vector two and went all the way down to 1 for dash speed and it still goes a ridiculous distance.
not really sure what the issue could be, is there a way i could send a copy of the project?
or would it help if i just sent the entire code for the player.
consumetur | 2023-01-04 05:43