Hey there everyone, I am quite new to C++ and have implemented some code for an invisibility spell/command. What currently happens is I press "1" then the character goes invisible, it activates a timer (InvisibilityStop) timer plays out, then the character reappears on it's own as intended, while another timer(InvisibilityCooldown) is playing so i can't immediately go invisible again. I just want to be able to go Visible whenever i am Invisible but i want there to be a corresponding timer so i can't go invisible right away, i also would like this timer to be the remaining time of the "InvisibilityCooldown". Here is the code.
void AOmniCharacter::GoInvisible()
{
if (VisibilityNegate)
{
GetInvisibleMesh()->ToggleVisibility();
ACharacter::GetMesh()->ToggleVisibility();
VisibilityNegate = false;
GetWorldTimerManager().SetTimer(InvisibilityHandle, this, &AOmniCharacter::StopInvisibilty, InvisibilityStop, true);
}
}
void AOmniCharacter::StopInvisibilty()
{
GetInvisibleMesh()->ToggleVisibility();
ACharacter::GetMesh()->ToggleVisibility();
GetWorldTimerManager().SetTimer(InvisibilityHandle, this, &AOmniCharacter::ResetInvisibilitySpell, InvisibilityCooldown, false);
}
void AOmniCharacter::ResetInvisibilitySpell()
{
VisibilityNegate = true;
Please help, i can't figure this out, I also do not wish to tie this spell into a mana system.
Thankyou.