What's the proper way to call a function from OnSyncedInput just once?

Say I wanted to call for something like a UI button press on mousedown or up. I know if I simply tossed a (buttondown) input into SyncedInput it won't work unless it happens the same time the input frame gets sent. Or if I want to allow the player to shorthop via input.button(space), but if they press and release it too quickly no jump will go through. So I've been using a workaround but maybe I'm making it more complicated than it needs to be? Maybe there's a built-in solution I'm missing? Something that makes sure an input gets sent at least and/or at most once on the next input frame? (That'd be such a great QOL tool)

What I've been doing is I change a bool and update what gets sent in SyncedInput based on that bool. A "cooldown" timer ticks down (from about 0.25 or so) and the function I need to play gets played if that cooldown timer is <= 0 and the bool comes back true, play the function and reset the cooldown. On top of that (if needed) I do another check which will check if the player released the key, so he has to release and hit the key again before the function plays again.
Simple enough for most things, but for others it can get way more complex with many more checks.


  • Hello @Wheathn, we don't have yet a bult-in solution for interactions like press a button up/down, you noticed correctly when it works on a default SyncedIpnput implementation. You can look in "SimpleControl.cs" script how we did to simulate a button down.