diff options
author | Daniel Weipert <code@drogueronin.de> | 2021-02-12 20:21:05 +0100 |
---|---|---|
committer | Daniel Weipert <code@drogueronin.de> | 2021-02-12 20:21:05 +0100 |
commit | 332bab8de321d0358b30d5bf159cbda512c14852 (patch) | |
tree | 72ec7578422ede5df7486a7515fc6353fa6c5d82 | |
parent | b9a9f986c6e6e39e03418fff3c8748273575a47a (diff) |
Adds variable jump height
-rw-r--r-- | Characters/Character.gd | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/Characters/Character.gd b/Characters/Character.gd index e5623b1..a60046b 100644 --- a/Characters/Character.gd +++ b/Characters/Character.gd @@ -10,6 +10,7 @@ var direction = Enum.DIRECTION.RIGHT var canDoubleJump = false var hasPlayedFallStop = false +var jumpHeightModifier = 0 func _physics_process(_delta): @@ -65,9 +66,16 @@ func _physics_process(_delta): if is_on_floor(): canDoubleJump = true velocity.y = JUMPFORCE + jumpHeightModifier = JUMPFORCE elif not is_on_floor() and not is_on_wall() and canDoubleJump: canDoubleJump = false velocity.y = JUMPFORCE + if Input.is_action_pressed("ui_up"): + jumpHeightModifier += 10 + if jumpHeightModifier > 0: + jumpHeightModifier = 0 + if Input.is_action_just_released("ui_up"): + velocity.y -= jumpHeightModifier if is_on_wall(): |