Ability to dash from wall slide
This commit is contained in:
parent
9bdaef2d86
commit
97fcc5fef4
2 changed files with 37 additions and 32 deletions
|
@ -105,14 +105,19 @@ func calculate_move_velocity(direction:Vector2, is_jump_canceled:bool, delta:fl
|
||||||
0
|
0
|
||||||
)
|
)
|
||||||
|
|
||||||
if Input.is_action_just_pressed("dash") and _can_dash and !_is_wall_sliding:
|
if Input.is_action_just_pressed("dash") and _can_dash:
|
||||||
output = dash_velocity
|
|
||||||
_can_dash = false
|
_can_dash = false
|
||||||
_is_dashing = true # turn off gravity while dashing
|
_is_dashing = true # turn off gravity while dashing
|
||||||
|
# Wall dash first
|
||||||
|
if _is_wall_sliding:
|
||||||
|
dash_velocity.x = (-1 if _is_next_to_wall_right() else 1) * dash_thrust
|
||||||
|
|
||||||
if dash_velocity.x < 0 :
|
if dash_velocity.x < 0 :
|
||||||
$DashParticlesLeft.emitting = true;
|
$DashParticlesLeft.emitting = true;
|
||||||
else:
|
else:
|
||||||
$DashParticlesRight.emitting = true
|
$DashParticlesRight.emitting = true
|
||||||
|
output = dash_velocity
|
||||||
$DashTimeout.start()
|
$DashTimeout.start()
|
||||||
|
|
||||||
return output;
|
return output;
|
||||||
|
@ -139,7 +144,7 @@ func _is_next_to_wall_left():
|
||||||
return colider.name == "SolidsTileMap"
|
return colider.name == "SolidsTileMap"
|
||||||
return false
|
return false
|
||||||
|
|
||||||
func update_sprite(direction:Vector2)->void:
|
func update_sprite(_direction:Vector2) -> void:
|
||||||
var air_animation = "jump" if _velocity.y <= 0 else "fall"
|
var air_animation = "jump" if _velocity.y <= 0 else "fall"
|
||||||
if _velocity.x > .5 and not _is_wall_sliding:
|
if _velocity.x > .5 and not _is_wall_sliding:
|
||||||
$AnimationPlayer.play("run" if is_on_floor() else air_animation)
|
$AnimationPlayer.play("run" if is_on_floor() else air_animation)
|
||||||
|
@ -158,8 +163,8 @@ func update_sprite(direction:Vector2)->void:
|
||||||
return
|
return
|
||||||
|
|
||||||
if _is_dashing:
|
if _is_dashing:
|
||||||
return
|
|
||||||
$AnimationPlayer.play("jump")
|
$AnimationPlayer.play("jump")
|
||||||
|
return
|
||||||
|
|
||||||
func _on_die_animation_done():
|
func _on_die_animation_done():
|
||||||
emit_signal("died")
|
emit_signal("died")
|
||||||
|
|
File diff suppressed because one or more lines are too long
Loading…
Reference in a new issue