Ranter
Join devRant
Do all the things like
++ or -- rants, post your own rants, comment on others' rants and build your customized dev avatar
Sign Up
Pipeless API
From the creators of devRant, Pipeless lets you power real-time personalized recommendations and activity feeds using a simple API
Learn More
Comments
-
aaeim3168yHey after 18 hrs no stop, your brain starts processing things slower. At that point if it runs it's good lol. Gamejams are fun!
I bet that piece of code is inside a OnTriggerEnter (Collider other) Unity ftw! -
RexOmni5458yWell, because it is a function that takes a string as a parameter, which then takes it to the key code/axis, and then takes it to the actual keyboard state.
I believe they were right to do so. Functions can be expensive. -
I'm with @RexOmni here, that's not redundant. This reminds me of the new guy at my office that makes outbursts insulting others' code all the time. He still hasn't learned that for 90% of his insulting outbursts, there's something in the logic that has to be explained... Don't be that guy.
-
aaeim3168yDoesn't look to me like he is insulting anyone's code. More like laughing at his own. We don't have much context but since one of the team members posted it as redundant, I think it's safe to assume that the activate flag was unnecessary.
-
Urkaz218y@neotelos @RexOmni As @aaeim said, the resundant part is the activated flag (it isn't needed at all). This is a onTriggerStay Unity function that reads the "E" key input (0 not pressed, 1 pressed). The point here is: if the key is pressed the flag is set to true, then it is checked and set to false. That can be done the same way just moving the contents of the second if to the first one without changing the flag value xD
Related Rants
Found this pearl on the code of the game I made with some friends on a game jam the last week
Beautiful
undefined
gamedev
redundant code is redundant
game jam