Mejoras en el manejo del personaje, enemigo de pruebas
This commit is contained in:
1 parent
1b797a3e90
commit
e93efc533b
21 files changed
+774
-85
No files matched your search
+27
-5
@@ -32,9 +32,20 @@ const ENEMY_HURTBOX_MASK: int = 1 << 4
|
||||
|
||||
@export_category("Movement")
|
||||
|
||||
@export var ground_acceleration: float = 2200.0
|
||||
@export var ground_friction: float = 2600.0
|
||||
@export var air_acceleration: float = 1000.0
|
||||
## Reaches full running speed quickly, but not instantly.
|
||||
@export var ground_acceleration: float = 3600.0
|
||||
|
||||
## Used when there is no horizontal input. Slightly stronger than acceleration
|
||||
## so releasing the controls feels precise instead of slippery.
|
||||
@export var ground_friction: float = 4800.0
|
||||
|
||||
## Braking used only when the player asks for the opposite direction. The
|
||||
## character loses the old momentum first and then accelerates the other way,
|
||||
## producing a small but readable turn delay.
|
||||
@export var turn_braking: float = 5600.0
|
||||
|
||||
## Air control stays responsive but weaker than movement on the floor.
|
||||
@export var air_acceleration: float = 1800.0
|
||||
|
||||
|
||||
# ============================================================================
|
||||
@@ -212,8 +223,19 @@ func _handle_horizontal_movement(delta: float) -> void:
|
||||
return
|
||||
|
||||
if is_on_floor():
|
||||
var acceleration: float = ground_acceleration if direction != 0.0 else ground_friction
|
||||
velocity.x = move_toward(velocity.x, target_speed, acceleration * delta)
|
||||
if direction == 0.0:
|
||||
velocity.x = move_toward(velocity.x, 0.0, ground_friction * delta)
|
||||
elif velocity.x != 0.0 and signf(velocity.x) != signf(direction):
|
||||
# Do not snap directly from full speed right to full speed left. Brake
|
||||
# the previous momentum first; on the next frames normal acceleration
|
||||
# takes over in the requested direction.
|
||||
velocity.x = move_toward(velocity.x, 0.0, turn_braking * delta)
|
||||
else:
|
||||
velocity.x = move_toward(
|
||||
velocity.x,
|
||||
target_speed,
|
||||
ground_acceleration * delta
|
||||
)
|
||||
else:
|
||||
velocity.x = move_toward(velocity.x, target_speed, air_acceleration * delta)
|
||||
|
||||
|
||||
Reference in new issue
Block a user