Silent jump and fall damage

This commit is contained in:
Rendo 2025-12-14 20:56:39 +05:00
commit c04a29b9c4
3 changed files with 7421 additions and 7404 deletions

File diff suppressed because one or more lines are too long

View file

@ -11,6 +11,7 @@ class_name Player
$Camera3D.set_multiplayer_authority(id)
var passived: bool = false
var previous_velocity: Vector3
signal health_changed(to: int)
signal damaged
@ -43,7 +44,7 @@ func _ready() -> void:
func _physics_process(_delta: float) -> void:
if not multiplayer.is_server():
return
previous_velocity = velocity
move_and_slide()
func die() -> void:
@ -68,6 +69,8 @@ func depassive() -> void:
passived = false
func take_damage(damage: int):
if damage == 0:
return
if dead:
return
hp -= damage

View file

@ -6,6 +6,8 @@ extends State
@export var max_speed: float = 5.0
@export var acceleration: float
@export var weapon_system: WeaponSystem
@export var damage_curve: Curve
@export var sound_threshold: float
@export var land_sound: MultiplayerAudio3D
func _enter() -> void:
@ -25,7 +27,12 @@ func physics_update(delta: float) -> void:
transition.emit("Walk")
else:
transition.emit("Stand")
land_sound.multiplayer_play()
var speed: float = -player.previous_velocity.y
player.take_damage(int(damage_curve.sample(speed)))
print(speed)
if speed > sound_threshold:
land_sound.multiplayer_play()
player.velocity += player.get_gravity() * delta