💫 Smooth health bar
This commit is contained in:
		@@ -107,10 +107,18 @@ public partial class Player : CharacterBody2D
 | 
			
		||||
    [Rpc(MultiplayerApi.RpcMode.AnyPeer, CallLocal = true)]
 | 
			
		||||
    private void GotDamage(double damage)
 | 
			
		||||
    {
 | 
			
		||||
        Health -= damage;
 | 
			
		||||
        var protection = GetNode<Timer>("ProtectionCountdown");
 | 
			
		||||
 | 
			
		||||
        var bar = GetNode<ProgressBar>("HUD/HealthBar");
 | 
			
		||||
        bar.Value = Health / MaxHealth * 100;
 | 
			
		||||
        if (protection.IsStopped())
 | 
			
		||||
        {
 | 
			
		||||
            Health -= damage;
 | 
			
		||||
 | 
			
		||||
            var tween = CreateTween();
 | 
			
		||||
            var bar = GetNode<ProgressBar>("HUD/HealthBar");
 | 
			
		||||
            tween.TweenProperty(bar, "value", Health / MaxHealth * 100, 0.3);
 | 
			
		||||
            
 | 
			
		||||
            protection.Start();
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        var shakableCamera = GetNode<CameraShake>("Camera2D");
 | 
			
		||||
        shakableCamera.AddTrauma(0.5f);
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user