T
T
trzp2020-12-14 12:19:39
Unity
trzp, 2020-12-14 12:19:39

How, after taking damage by a character, give him invulnerability for a certain time?

Hello. I am a beginner learning Unity 3D writing in C#. I am making one game. Now I'm faced with a problem: how, when taking damage, does the main character get invulnerability, for example, for 2 seconds (he has already implemented the taking of damage)? Thanks in advance

Answer the question

In order to leave comments, you need to log in

1 answer(s)
F
freeExec, 2020-12-14
@trzp

bool ПофигНаДамаг => ОставшеесяВремяНеуязвимости > 0;
Update()
{
if ОставшеесяВремяНеуязвимости > 0 
    ОставшеесяВремяНеуязвимости -= Time.deltaTime;
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question