add friction to slow velocity rather than resetting it (#8)
* add friction to slow velocity rather than resetting it * Resolve merge conflict * Revert "add friction to slow velocity rather than resetting it" This reverts commit b21ea684ba339d9dfa7d682ed490b5b8f5f2f9e3. * re-add change
This commit is contained in:
@@ -7,6 +7,8 @@ const BASE_MOVE_SPEED: float = 5
|
||||
const SPRINT_MOVE_SPEED: float = 8
|
||||
const BASE_HEIGHT: float = 2.0
|
||||
const CROUCH_HEIGHT: float = 1.0
|
||||
const FRICTION: float = 0.2
|
||||
const AIR_FRICTION: float = 0.025
|
||||
const CROUCH_TRANSITION_SPEED: float = 0.1
|
||||
|
||||
enum MovementMode {
|
||||
@@ -62,8 +64,17 @@ func handle_movement(delta: float) -> void:
|
||||
"move_forward", "move_backward")
|
||||
|
||||
var movement_dir := transform.basis * Vector3(input.x, 0, input.y)
|
||||
velocity.x = movement_dir.x * move_speed
|
||||
velocity.z = movement_dir.z * move_speed
|
||||
if movement_dir.x == 0:
|
||||
velocity.x = lerpf(velocity.x, 0.0,
|
||||
FRICTION if is_on_floor() else AIR_FRICTION)
|
||||
else:
|
||||
velocity.x = movement_dir.x * move_speed
|
||||
|
||||
if movement_dir.z == 0:
|
||||
velocity.z = lerpf(velocity.z, 0.0,
|
||||
FRICTION if is_on_floor() else AIR_FRICTION)
|
||||
else:
|
||||
velocity.z = movement_dir.z * move_speed
|
||||
|
||||
func handle_state_transition() -> void:
|
||||
match current_movement:
|
||||
|
||||
Reference in New Issue
Block a user