Implemented physics interpolation

This commit is contained in:
2024-02-27 21:05:55 +01:00
parent ca7fa120ea
commit 489a14061a
23 changed files with 226 additions and 68 deletions

View File

@ -1,5 +1,5 @@
class_name DeathComponent
extends Node
extends CharacterComponent
@export var health: HealthComponent
@export var hud: HUDComponent
@ -10,7 +10,7 @@ extends Node
var respawn_position: Vector3
func _ready():
respawn_position = owner.global_position
respawn_position = character.global_position
health.death.connect(on_death)
func on_death():
@ -21,20 +21,20 @@ func on_death():
func drop_loot():
var loot := drop.instantiate() as Node3D
owner.get_parent().add_child(loot)
loot.global_position = owner.global_position + loot.position
character.get_parent().add_child(loot)
loot.global_position = character.global_position + loot.position
func die():
DeathComponent.set_physics(owner, false)
DeathComponent.set_physics(character, false)
hud.visible = false
animation.play("slime_death")
func revive():
health.restore()
DeathComponent.set_physics(owner, true)
DeathComponent.set_physics(character, true)
hud.visible = true
(owner as Node3D).transform = Transform3D.IDENTITY
owner.global_position = respawn_position
character.transform = Transform3D.IDENTITY
character.global_position = respawn_position
animation.play("slime_idle")
static func set_physics(obj: Node3D, alive: bool):