@@ -68,74 +68,74 @@ signal stopped_floating
6868## Controller Gravity Multiplier
6969## The higher the number, the faster the controller will fall to the ground and
7070## your jump will be shorter.
71- @export var gravity_multiplier := 3.0
71+ @export var gravity_multiplier : float = 3.0
7272
7373## Controller base speed
7474## Note: this speed is used as a basis for abilities to multiply their
7575## respective values, changing it will have consequences on [b]all abilities[/b]
7676## that use velocity.
77- @export var speed := 10
77+ @export var speed : float = 10.0
7878
7979## Time for the character to reach full speed
80- @export var acceleration := 8
80+ @export var acceleration : float = 8.0
8181
8282## Time for the character to stop walking
83- @export var deceleration := 10
83+ @export var deceleration : float = 10.0
8484
8585## Sets control in the air
86- @export var air_control := 0.3
86+ @export var air_control : float = 0.3
8787
8888
8989@export_group ("Sprint" )
9090
9191## Speed to be multiplied when active the ability
92- @export var sprint_speed_multiplier := 1.6
92+ @export var sprint_speed_multiplier : float = 1.6
9393
9494
9595@export_group ("Footsteps" )
9696
9797## Maximum counter value to be computed one step
98- @export var step_lengthen := 0.7
98+ @export var step_lengthen : float = 0.7
9999
100100## Value to be added to compute a step, each frame that the character is walking this value
101101## is added to a counter
102- @export var step_interval := 6.0
102+ @export var step_interval : float = 6.0
103103
104104
105105@export_group ("Crouch" )
106106
107107## Collider height when crouch actived
108- @export var height_in_crouch := 1.0
108+ @export var height_in_crouch : float = 1.0
109109
110110## Speed multiplier when crouch is actived
111- @export var crouch_speed_multiplier := 0.7
111+ @export var crouch_speed_multiplier : float = 0.7
112112
113113
114114@export_group ("Jump" )
115115
116116## Jump/Impulse height
117- @export var jump_height := 10
117+ @export var jump_height : float = 10.0
118118
119119
120120@export_group ("Fly" )
121121
122122## Speed multiplier when fly mode is actived
123- @export var fly_mode_speed_modifier := 2
123+ @export var fly_mode_speed_modifier : float = 2.0
124124
125125
126126@export_group ("Swim" )
127127
128128## Minimum height for [CharacterController3D] to be completely submerged in water.
129- @export var submerged_height := 0.36
129+ @export var submerged_height : float = 0.36
130130
131131## Minimum height for [CharacterController3D] to be float in water.
132- @export var floating_height := 0.75
132+ @export var floating_height : float = 0.75
133133
134134## Speed multiplier when floating water
135- @export var on_water_speed_multiplier := 0.75
135+ @export var on_water_speed_multiplier : float = 0.75
136136
137137## Speed multiplier when submerged water
138- @export var submerged_speed_multiplier := 0.5
138+ @export var submerged_speed_multiplier : float = 0.5
139139
140140
141141@export_group ("Abilities" )
@@ -155,7 +155,7 @@ var _step_cycle : float = 0
155155var _next_step : float = 0
156156
157157## Character controller horizontal speed.
158- var _horizontal_velocity
158+ var _horizontal_velocity : Vector3
159159
160160## Base transform node to direct player movement
161161## Used to differentiate fly mode/swim moves from regular character movement.
@@ -189,7 +189,7 @@ var _direction_base_node : Node3D
189189@onready var swim_ability : SwimAbility3D = get_node (NodePath ("Swim Ability 3D" ))
190190
191191## Stores normal speed
192- @onready var _normal_speed : int = speed
192+ @onready var _normal_speed : float = speed
193193
194194## True if in the last frame it was on the ground
195195var _last_is_on_floor := false
@@ -220,7 +220,7 @@ func move(_delta: float, input_axis := Vector2.ZERO, input_jump := false, input_
220220 jump_ability .set_active (input_jump and is_on_floor () and not head_check .is_colliding ())
221221 walk_ability .set_active (not is_fly_mode () and not swim_ability .is_floating ())
222222 crouch_ability .set_active (input_crouch and is_on_floor () and not is_floating () and not is_submerged () and not is_fly_mode ())
223- sprint_ability .set_active (input_sprint and is_on_floor () and input_axis .x >= 0.5 and ! is_crouching () and not is_fly_mode () and not swim_ability .is_floating () and not swim_ability .is_submerged ())
223+ sprint_ability .set_active (input_sprint and is_on_floor () and input_axis .y >= 0.5 and ! is_crouching () and not is_fly_mode () and not swim_ability .is_floating () and not swim_ability .is_submerged ())
224224
225225 var multiplier = 1.0
226226 for ability in _abilities :
@@ -321,7 +321,7 @@ func _start_variables():
321321
322322func _check_landed ():
323323 if is_on_floor () and not _last_is_on_floor :
324- emit_signal ( "landed" )
324+ _on_landed ( )
325325 _reset_step ()
326326 _last_is_on_floor = is_on_floor ()
327327
@@ -334,13 +334,13 @@ func _check_step(_delta):
334334func _direction_input (input : Vector2 , input_down : bool , input_up : bool , aim_node : Node3D ) -> Vector3 :
335335 _direction = Vector3 ()
336336 var aim = aim_node .get_global_transform ().basis
337- if input .x >= 0.5 :
337+ if input .y >= 0.5 :
338338 _direction -= aim .z
339- if input .x <= - 0.5 :
340- _direction += aim .z
341339 if input .y <= - 0.5 :
340+ _direction += aim .z
341+ if input .x <= - 0.5 :
342342 _direction -= aim .x
343- if input .y >= 0.5 :
343+ if input .x >= 0.5 :
344344 _direction += aim .x
345345 # NOTE: For free-flying and swimming movements
346346 if is_fly_mode () or is_floating ():
@@ -395,6 +395,10 @@ func _on_jumped():
395395 emit_signal ("jumped" )
396396
397397
398+ func _on_landed ():
399+ emit_signal ("landed" )
400+
401+
398402func _on_swim_ability_emerged ():
399403 emit_signal ("emerged" )
400404
0 commit comments