Silent jump and fall damage
This commit is contained in:
parent
43a0fd1b20
commit
c04a29b9c4
3 changed files with 7421 additions and 7404 deletions
14811
players/molikman.tscn
14811
players/molikman.tscn
File diff suppressed because one or more lines are too long
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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,6 +27,11 @@ func physics_update(delta: float) -> void:
|
|||
transition.emit("Walk")
|
||||
else:
|
||||
transition.emit("Stand")
|
||||
|
||||
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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue