improve player controls
This commit is contained in:
parent
48e807f7cd
commit
ec8dd43b1f
|
@ -4,7 +4,7 @@ onready var util = get_node("/root/Util")
|
|||
|
||||
export var gravity: float = 6.0
|
||||
# When falling, gravity is artificially increased
|
||||
export var gravity_downwards_factor: float = 2
|
||||
export var gravity_downwards_factor: float = 3
|
||||
# Rate of gaining speed
|
||||
export var velocity_acceleration_xz: float = 3
|
||||
export var velocity_acceleration_y: float = 5
|
||||
|
@ -14,10 +14,8 @@ export var velocity_friction_y: float = 1
|
|||
export var jump_power: float = 50
|
||||
|
||||
# Controls the base speeds of walking and sprinting
|
||||
export var sprint_factor: float = 1.5
|
||||
export var walk_factor: float = 1.0
|
||||
|
||||
export var max_xz_speed: float = 2
|
||||
export var sprint_factor: float = 3.5
|
||||
export var walk_factor: float = 1.5
|
||||
|
||||
"public" var velocity: Vector3 = Vector3.ZERO
|
||||
# Value changed by code only to add slow down or speed up effects
|
||||
|
@ -56,7 +54,11 @@ func process_velocity(delta: float):
|
|||
is_jumping = false
|
||||
|
||||
|
||||
var target_velocity_xz = $"../MovementInput".input_xz
|
||||
var target_velocity_xz = $"../MovementInput".input_xz
|
||||
if $"../MovementInput".sprinting:
|
||||
target_velocity_xz *= sprint_factor
|
||||
else:
|
||||
target_velocity_xz *= walk_factor
|
||||
target_velocity = util.vec2_xz_to_vec3(target_velocity_xz, target_velocity.y)
|
||||
var velocity_xz = util.vec3_xz(velocity)
|
||||
|
||||
|
@ -79,15 +81,9 @@ func process_velocity(delta: float):
|
|||
|
||||
var velocity_y = util.clamped_lerp(velocity.y, target_velocity.y, y_weight, 0.25)
|
||||
|
||||
if $"../MovementInput".sprinting:
|
||||
velocity_xz *= sprint_factor
|
||||
else:
|
||||
velocity_xz *= walk_factor
|
||||
|
||||
velocity = util.vec2_xz_to_vec3(velocity_xz, velocity_y) * velocity_factor
|
||||
|
||||
velocity = util.vec2_xz_to_vec3(util.vec3_xz(velocity).limit_length(max_xz_speed), velocity.y)
|
||||
|
||||
func increase_velocity_factor(by: Vector3):
|
||||
velocity_factor *= by
|
||||
|
||||
|
|
Loading…
Reference in New Issue