From 332bab8de321d0358b30d5bf159cbda512c14852 Mon Sep 17 00:00:00 2001 From: Daniel Weipert Date: Fri, 12 Feb 2021 20:21:05 +0100 Subject: Adds variable jump height --- Characters/Character.gd | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'Characters/Character.gd') 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(): -- cgit v1.2.3