Zombie flash

This commit is contained in:
Фёдор Веселов 2024-09-25 15:47:51 +05:00
commit eb2159811e
4 changed files with 73 additions and 2 deletions

View file

@ -0,0 +1,34 @@
using Godot;
using System;
public partial class FlashComponent : CanvasGroup
{
[Export] private float _flashDuration = 0.1f;
private Tween _tween;
private ShaderMaterial _shaderMaterial;
public override void _Ready()
{
_shaderMaterial = Material as ShaderMaterial;
}
public void DamageFlash(int damage)
{
Flash();
}
public void Flash()
{
_tween?.Kill();
_tween = CreateTween();
Action<float> action = SetAmount;
_tween.TweenMethod(Callable.From(action),1.0f,0.0f,_flashDuration);
}
private void SetAmount(float amount)
{
_shaderMaterial.SetShaderParameter("amount",amount);
}
}