@@ -3,11 +3,12 @@ extends CharacterBody3D
3
3
const EYE_HEIGHT_STAND = 1.6
4
4
const EYE_HEIGHT_CROUCH = 1.4
5
5
6
- const MOVEMENT_SPEED_GROUND = 0.6
7
- const MOVEMENT_SPEED_AIR = 0.11
6
+ const MOVEMENT_SPEED_GROUND = 70.0
7
+ const MOVEMENT_SPEED_AIR = 13.0
8
8
const MOVEMENT_SPEED_CROUCH_MODIFIER = 0.5
9
- const MOVEMENT_FRICTION_GROUND = 0.9
10
- const MOVEMENT_FRICTION_AIR = 0.98
9
+ const MOVEMENT_FRICTION_GROUND = 12.5
10
+ const MOVEMENT_FRICTION_AIR = 2.25
11
+ const MOVEMENT_JUMP_VELOCITY = 7.25
11
12
12
13
var _mouse_motion := Vector2 ()
13
14
var _selected_block := 6
@@ -81,7 +82,7 @@ func _physics_process(delta: float) -> void:
81
82
camera_attributes .dof_blur_far_transition = Settings .fog_distance * 0.125
82
83
# Crouching.
83
84
var crouching := Input .is_action_pressed (& "crouch" )
84
- head .transform .origin .y = lerpf (head .transform .origin .y , EYE_HEIGHT_CROUCH if crouching else EYE_HEIGHT_STAND , 16 * delta )
85
+ head .transform .origin .y = lerpf (head .transform .origin .y , EYE_HEIGHT_CROUCH if crouching else EYE_HEIGHT_STAND , 1.0 - exp ( - delta * 16.0 ) )
85
86
86
87
# Keyboard movement.
87
88
var movement_vec2 := Input .get_vector ("move_left" , "move_right" , "move_forward" , "move_back" )
@@ -96,23 +97,24 @@ func _physics_process(delta: float) -> void:
96
97
movement *= MOVEMENT_SPEED_CROUCH_MODIFIER
97
98
98
99
# Gravity.
99
- velocity .y -= gravity * delta
100
+ if not is_on_floor ():
101
+ velocity .y -= gravity * delta
100
102
101
- velocity += Vector3 (movement .x , 0 , movement .z )
103
+ velocity += Vector3 (movement .x , 0 , movement .z ) * delta
102
104
# Apply horizontal friction.
103
- velocity . x *= MOVEMENT_FRICTION_GROUND if is_on_floor () else MOVEMENT_FRICTION_AIR
104
- velocity . z *= MOVEMENT_FRICTION_GROUND if is_on_floor () else MOVEMENT_FRICTION_AIR
105
+ var friction_delta := exp ( - ( MOVEMENT_FRICTION_GROUND if is_on_floor () else MOVEMENT_FRICTION_AIR ) * delta )
106
+ velocity = Vector3 ( velocity . x * friction_delta , velocity . y , velocity . z * friction_delta )
105
107
move_and_slide ()
106
108
107
109
# Jumping, applied next frame.
108
110
if is_on_floor () and Input .is_action_pressed (& "jump" ):
109
- velocity .y = 7.5
111
+ velocity .y = MOVEMENT_JUMP_VELOCITY
110
112
111
113
112
114
func _input (event : InputEvent ) -> void :
113
115
if event is InputEventMouseMotion :
114
116
if Input .get_mouse_mode () == Input .MOUSE_MODE_CAPTURED :
115
- _mouse_motion += event .relative
117
+ _mouse_motion += event .screen_relative
116
118
117
119
118
120
func chunk_pos () -> Vector3i :
0 commit comments