Implermented health

This commit is contained in:
Michel 2025-02-02 02:23:55 +01:00
parent 76e5b1927f
commit e6391d9fdd
13 changed files with 142 additions and 109 deletions

View file

@ -13,6 +13,7 @@ static var Instance: Player;
@onready var animationtree: AnimationTree = $CollisionShape3D/Camera3D/Weapon/AnimationPlayer/AnimationTree
@onready var collisionShape: CollisionShape3D = $CollisionShape3D
@onready var health: Health = $Health
@onready var enemyTarget: Node3D = $"Enemy Target"
const CROUCHED_SPEED: float = 2.5
const SPEED: float = 5.0
@ -28,6 +29,7 @@ var gravity: float = ProjectSettings.get_setting("physics/3d/default_gravity")
func _ready() -> void:
Instance = self
health.damaged.connect(self.damaged)
func _physics_process(delta: float) -> void:
# Add the gravity.
@ -79,7 +81,7 @@ func _physics_process(delta: float) -> void:
lastDirection.y = move_toward(lastDirection.y, input_dir.y, 0.05);
var yLeft = clamp(lastDirection.y - 1, 0, 1);
animationtree.set('parameters/Movement/blend_position', yLeft)
var yRemainder = Vector2(lastDirection.x, clamp(lastDirection.y, 0, 1));
var yRemainder = Vector2(lastDirection.x, clamp(lastDirection.y, -1, 1));
animationtree.set(blendProperty, yRemainder);
func handleCrouching():
@ -91,3 +93,6 @@ func handleCrouching():
self.PlayerState = PlayerStates.STANDING
(collisionShape.shape as CylinderShape3D).height = 2
self.animationtree['parameters/playback'].travel('Movement')
func damaged():
print("Damage")