Files
FPS/Scripts/PlayerHUD.cs
2023-08-04 14:18:28 -07:00

18 lines
363 B
C#

using System.Linq;
using Godot;
public partial class PlayerHUD : CanvasLayer
{
public override void _Ready()
{
UpdateCurrentAmmo();
}
public void UpdateCurrentAmmo()
{
var gun = GetNode<Gun>("/root/Player/Gun");
var ammoLabel = GetChildren().Single(x => x.Name == "AmmoLabel") as Label;
ammoLabel.Text = $"{gun.CurrentAmmo}/30";
}
}