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)
|
$Camera3D.set_multiplayer_authority(id)
|
||||||
|
|
||||||
var passived: bool = false
|
var passived: bool = false
|
||||||
|
var previous_velocity: Vector3
|
||||||
|
|
||||||
signal health_changed(to: int)
|
signal health_changed(to: int)
|
||||||
signal damaged
|
signal damaged
|
||||||
|
|
@ -43,7 +44,7 @@ func _ready() -> void:
|
||||||
func _physics_process(_delta: float) -> void:
|
func _physics_process(_delta: float) -> void:
|
||||||
if not multiplayer.is_server():
|
if not multiplayer.is_server():
|
||||||
return
|
return
|
||||||
|
previous_velocity = velocity
|
||||||
move_and_slide()
|
move_and_slide()
|
||||||
|
|
||||||
func die() -> void:
|
func die() -> void:
|
||||||
|
|
@ -68,6 +69,8 @@ func depassive() -> void:
|
||||||
passived = false
|
passived = false
|
||||||
|
|
||||||
func take_damage(damage: int):
|
func take_damage(damage: int):
|
||||||
|
if damage == 0:
|
||||||
|
return
|
||||||
if dead:
|
if dead:
|
||||||
return
|
return
|
||||||
hp -= damage
|
hp -= damage
|
||||||
|
|
|
||||||
|
|
@ -6,6 +6,8 @@ extends State
|
||||||
@export var max_speed: float = 5.0
|
@export var max_speed: float = 5.0
|
||||||
@export var acceleration: float
|
@export var acceleration: float
|
||||||
@export var weapon_system: WeaponSystem
|
@export var weapon_system: WeaponSystem
|
||||||
|
@export var damage_curve: Curve
|
||||||
|
@export var sound_threshold: float
|
||||||
@export var land_sound: MultiplayerAudio3D
|
@export var land_sound: MultiplayerAudio3D
|
||||||
|
|
||||||
func _enter() -> void:
|
func _enter() -> void:
|
||||||
|
|
@ -25,6 +27,11 @@ func physics_update(delta: float) -> void:
|
||||||
transition.emit("Walk")
|
transition.emit("Walk")
|
||||||
else:
|
else:
|
||||||
transition.emit("Stand")
|
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()
|
land_sound.multiplayer_play()
|
||||||
|
|
||||||
player.velocity += player.get_gravity() * delta
|
player.velocity += player.get_gravity() * delta
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue