Fix some weird stuff in the sprinting code

This commit is contained in:
karl 2019-11-24 22:21:26 +01:00
parent 51325fb5ef
commit 1a63eb2a9b
2 changed files with 6 additions and 5 deletions

View File

@ -66,6 +66,7 @@ transform = Transform( 0.573576, 0, -0.819152, 0, 1, 0, 0.819152, 0, 0.573576, 1
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 45, 0, 48 ) transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 45, 0, 48 )
[node name="Walls" type="Spatial" parent="Navigation/NavigationMeshInstance"] [node name="Walls" type="Spatial" parent="Navigation/NavigationMeshInstance"]
editor/display_folded = true
[node name="Wall3" parent="Navigation/NavigationMeshInstance/Walls" instance=ExtResource( 3 )] [node name="Wall3" parent="Navigation/NavigationMeshInstance/Walls" instance=ExtResource( 3 )]
transform = Transform( 0.766044, 0, -0.642788, 0, 1, 0, 0.642788, 0, 0.766044, 38, 0, 22 ) transform = Transform( 0.766044, 0, -0.642788, 0, 1, 0, 0.642788, 0, 0.766044, 38, 0, 22 )

View File

@ -17,8 +17,8 @@ const MAX_SLOPE_ANGLE = 40
const MOUSE_SENSITIVITY = 0.05 const MOUSE_SENSITIVITY = 0.05
const MAX_MOUSE_SPEED = 25 const MAX_MOUSE_SPEED = 25
const INTERACT_DISTANCE = 4 const INTERACT_DISTANCE = 4
const SPRINT_DEC = 0.01; const SPRINT_DEC = 40
const SPRINT_ACC = 0.005; const SPRINT_ACC = 20
# private members # private members
var _body: Spatial var _body: Spatial
@ -68,9 +68,9 @@ func _physics_process(delta):
func _process(delta): func _process(delta):
_process_animations() _process_animations()
if _is_sprinting and _sprintVal > 0: if _is_sprinting and _sprintVal > 0:
_sprintVal -= SPRINT_DEC / delta _sprintVal -= SPRINT_DEC * delta
elif _sprintVal < 100: elif _sprintVal < 100:
_sprintVal += SPRINT_ACC / delta _sprintVal += SPRINT_ACC * delta
func _process_input(): func _process_input():
@ -111,7 +111,7 @@ func _process_input():
_vel.y = JUMP_SPEED _vel.y = JUMP_SPEED
# sprinting # sprinting
_is_sprinting = Input.is_action_pressed("move_sprint") and _sprintVal > SPRINT_DEC _is_sprinting = Input.is_action_pressed("move_sprint") and _sprintVal > 0
func _process_movement(delta): func _process_movement(delta):