Feat/2 weapons foundation #6
@@ -33,7 +33,22 @@ func enter(_data: Dictionary = {}) -> void:
|
|||||||
direction = direction.normalized()
|
direction = direction.normalized()
|
||||||
|
|
||||||
machine.register_chain_mechanic("dash")
|
machine.register_chain_mechanic("dash")
|
||||||
_exit_speed = machine.get_effective_speed(params.dash_speed)
|
|
||||||
|
var current_hvel := Vector3(machine.player.velocity.x, 0.0, machine.player.velocity.z)
|
||||||
|
var current_speed := current_hvel.length()
|
||||||
|
var proj := current_hvel.dot(direction)
|
||||||
|
|
||||||
|
var base_dash_speed = machine.get_effective_speed(params.dash_speed)
|
||||||
|
|
||||||
|
if proj >= 0.0:
|
||||||
|
# Dashing forward or diagonally forward: add base dash speed to the projected speed
|
||||||
|
_exit_speed = proj + base_dash_speed
|
||||||
|
else:
|
||||||
|
# Dashing backward or diagonally backward:
|
||||||
|
# Reflect current momentum into the new direction, smoothly scaling from base_dash_speed (at sideways) to current_speed (at exactly backward).
|
||||||
|
var backward_factor = -proj / current_speed if current_speed > 0.001 else 0.0
|
||||||
|
_exit_speed = lerpf(base_dash_speed, maxf(current_speed, base_dash_speed), backward_factor)
|
||||||
|
|
||||||
machine.player.velocity = direction * _exit_speed
|
machine.player.velocity = direction * _exit_speed
|
||||||
machine.on_ground = false
|
machine.on_ground = false
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user