C
C#•5d ago
Axivex

code only activating for a split moment

I think whats happening is since I put the 2 methods in an if statement, now they only run for a split second instead of updating every frame with void update. How do I make the methods update every frame so it works properly?
No description
7 Replies
Angius
Angius•5d ago
Seeing how it's Unity, Update() runs every frame So, most likely, something else is wrong A debugger would probably help
Axivex
AxivexOP•5d ago
huh the code works fine if I remove the if statements and just give it one of the 2 methods to run
ero
ero•5d ago
Unity's Random.Range returns a float with its upper bound being inclusive. Your conditions will almost never be true You should read the documentation of the methods you use
Angius
Angius•5d ago
float, float is inclusive int, int is exclusive So, yes, .Range(1, 3) will return either 1 or 2 That part is fine
ero
ero•5d ago
Really? There's an extra overload? Maybe I should read the docs of the stuff I talk about
Axivex
AxivexOP•5d ago
ok yall took wayyyy too long and trying like 7 different things before realizing it was just cause im setting cooldown = 0.0f at the start, but the if is only active if its 5.0f or higher 😭 im dumb well atleast its workin now

Did you find this page helpful?