Files
BABA_YAGA/Assets/Scripts/Interactables/HealthInteractable.cs

28 lines
794 B
C#
Raw Normal View History

2026-04-01 02:41:07 +07:00
using UnityEngine;
namespace OnlyScove.Scripts
{
public class HealthInteractable : BaseInteractable
{
[SerializeField] private float healAmount = 25f;
[SerializeField] private bool destroyOnInteract = true;
protected override void PerformInteraction(PlayerStateMachine player)
{
if (player.TryGetComponent(out Health health))
{
health.Heal(healAmount);
Debug.Log($"[Healing] Restored {healAmount} health.");
if (destroyOnInteract)
{
Destroy(gameObject);
}
}
else
{
Debug.LogWarning("[Healing] Player has no Health component!");
}
}
}
}