better healthbars and one for the player as well
All checks were successful
Create tag and build when new code gets to main / BumpTag (push) Successful in 42s
Create tag and build when new code gets to main / Test (push) Successful in 6m13s
Create tag and build when new code gets to main / Export (push) Successful in 7m5s

This commit is contained in:
2026-01-26 18:09:29 +01:00
parent 2fdc9c7ca8
commit ddf1bd019b
12 changed files with 190 additions and 49 deletions

View File

@@ -1,26 +1,14 @@
using Godot;
using System;
using Movementtests.interfaces;
[GlobalClass]
public partial class CHealthbar : Node3D
public partial class CHealthbar : Sprite3D
{
private Sprite3D _currentHealth;
private float _initialXScale;
private Healthbar _healthbar;
public Healthbar Healthbar => _healthbar;
public override void _Ready()
{
Visible = false;
_currentHealth = GetNode<Sprite3D>("Health");
_initialXScale = _currentHealth.Scale.X;
}
public void OnHealthChanged(HealthChangedRecord healthChanged)
{
if (healthChanged.MaxHealth == 0) return;
Visible = true;
var healthPercentage = healthChanged.CurrentHealth / healthChanged.MaxHealth;
_currentHealth.Scale = new Vector3(_initialXScale * healthPercentage, _currentHealth.Scale.Y, _currentHealth.Scale.Z);
_healthbar = GetNode<Healthbar>("%Healthbar");
}
}