replaced sprinting with mid air dash

This commit is contained in:
Derek
2024-08-10 21:49:40 -05:00
parent cb48827c8a
commit dad00cb0fa
6 changed files with 23 additions and 22 deletions

View File

@@ -15,8 +15,10 @@ var rng = RandomNumberGenerator.new()
@export var AUDIO = true
@export var dead_player : Resource
@export_group("Player Movement")
@export var WALK_SPEED = 7.0
@export var WALK_SPEED = 12.0
@export var SPRINT_SPEED = 15.0
@export var DASH_SPEED = 40
@export var DASH_STAM_REQ = 10
@export var MAX_STAMINA = 1800
@export var JUMP_VELOCITY = 10
@export var SENSITIVITY = .01
@@ -121,23 +123,27 @@ func _physics_process(delta):
elif Input.is_action_just_pressed("jump") and double_jump == true and !is_climbing:
velocity.y += JUMP_VELOCITY
double_jump = false
# Handle Sprint
if Input.is_action_pressed("sprint") and is_on_floor():
speed = SPRINT_SPEED
else:
speed = WALK_SPEED
speed = WALK_SPEED
# Get the input direction and handle the movement/deceleration.
var input_dir = Input.get_vector("move_left", "move_right", "move_up", "move_down")
var direction = (self.transform.basis * Vector3(input_dir.x, 0, input_dir.y)).normalized()
# Handle Sprint
if Input.is_action_just_pressed("sprint") and !is_on_floor():
if remaining_stamina >= DASH_STAM_REQ:
velocity.x += direction.x * DASH_SPEED
velocity.z += direction.z * DASH_SPEED
remaining_stamina -= 180
if is_on_floor() and !is_climbing:
if direction:
velocity.x = direction.x * speed
velocity.x = direction.x * speed
velocity.z = direction.z * speed
else:
velocity.x = lerp(velocity.x, direction.x * speed, delta * 6.5)
velocity.z = lerp(velocity.z, direction.z * speed, delta * 6.5)
velocity.x = lerp(velocity.x, direction.x * speed, delta * 6.5) + (direction.x * DASH_SPEED)
velocity.z = lerp(velocity.z, direction.z * speed, delta * 6.5) + (direction.z * DASH_SPEED)
elif is_climbing:
gravity = 0.0
if direction: