For some reason after I put the timer -= Time.deltaTime in a separate method it stopped working altogether. The CastSpell gets called in Update and all works fine, except for the timer part. If I were to just take it out and stick it in Update by itself it works no problem. I have also tried subtracting or adding any number to it but it just doesn’t budge.
I’d like to keep the timer in the CastSpell method so I can create different spells and not have 50 timers all separated.
this is the code I’m using. I call it in update and add a float and button in the parameters.
AH I see, any idea how to omit this because I’m kinda stumped. It’s not the biggest problem but it would’ve been nice to have everything done in one method instead of having 10 timers running at all times.
Your passing your timer by value. If the timer is in the same script as Update then should just use that variable instead of passing. If not then you would have to do it by reference.
When you pass a variable without a keyword it is passing by value meaning that it has no association with the variable you passed. With ‘ref’ you are referenced to the point of memory that holds the variable and not just a copy of its contents.