Hey guys!
I have a little game where my player (has a sprite renderer) gets hit by an enemy and after each hit I want to change his alpha value a little bit until he almost becomes transparent. I saw that it is possible by doing a color lerp or with the DOTween plugin. Sadly I didn’t manage to do it. That is what I have now:
private void Fade(float endValue, float fadeDuration, TweenCallback onEnd)
{
if(fadeTween != null)
{
fadeTween.Kill(false);
}
fadeTween = canvasGroup.DOFade(endValue, fadeDuration);
fadeTween.onComplete += onEnd;
}
private void FadeOut(float fadeDuration)
{
Fade(0f, fadeDuration, () =>
{
canvasGroup.interactable = false;
canvasGroup.blocksRaycasts = false;
});
}
Nothing happens to my player. Is something wrong in my code or is there another solution? I would be glad if someone can help me out