Is it bad to constantly set a variable to static value for duration of keypress in event tick?

Is it bad to constantly set a variable to a static value for duration of a keypress in event tick?

Event Tick()
 if BKeyPressed = True
 then setMaxSpeed = 5000

or should I always set the values in the keypress/released where button press only fire once?

(note: KeyPress Events only fire once)
ifBKeyPressed then setMaxSpeed = 5000
ifBKeyReleased then setMaxSpeed = 50

Obviously the latter seems more efficient, but does it matter? Is it okay to set a variable to the same value over and over in the event tick for the duration of a keypress?

The latter would put a lot less pressure on the system, depending on how fast your keypress event fires. Is there a reason you would need to set the variable to a specific value while the key is pressed? I can understand if the variable changes in the programming and you need to reset it again.

If you’re rotating the camera I want to change the yaw input scale from 2.5 to 1, but for mouse free look I want to leave the yaw input scale at 2.5

Well, if you only do what you showed above, then i might be unimportant. But think about doing this for all your “one time” events.

If you have events that only happen once in a while, don’t use EventTick. The Pressed/Released event is there to be used :smiley:

Sounds good.

I’ve made it a rule to never set a variable in the event tick unless it’s value is consistently changing (dynamic). If I set a variable to a static value that barely changes, it should only be once during an event that happens once.

Correct. I also feel better about having a setup where i know that i changed my variables. I often have a lot of notify calls that change stuff for me (depends on the game and situation).
For example notifying that a character is stunned. Why setting something that stops him from moving on tick, if i could just have the notification change all the values i need once, and revert them
once he’s not stunned anymore. That’s just a small example.