If I can take the opportunity to ask - what’s the advantage using UnityEvent + context (calls? I don’t know the verbiage) vs sending messages from the Player Input component to call methods?
this is quite similar so I have a duck script and when you put down then the player will duck and when it is released he will go back up so that is done with an if and if else how do I do that with this
Well if it is any help to others who come across this thread: While I wasn’t able to limit the event calling to only on press or release, I was able to determine what state the event was in.
For whatever reason the base objects event phase was useless, it was always in ‘processed’ (or something similar, it’s like midnight here when I’m writing this). However, the control object in the context was accurately reporting it’s button state.
So far the inputContext.control.IsPressed() has worked perfectly.
As a side-note if you don’t want your clicks to follow thru when you click over a UI element (uGUI), the line !EventSystem.current.IsPointerOverGameObject() works beautifully to terminate the event callback early. It won’t stop the action event from firing even though the UI was clicked as well, but this works great to cut it short. Also, it will log a warning into the console that it might be incorrect and shouldn’t be used in a callback context. But honestly it’s worked perfectly so far and better than any other solution I’ve come across.
Some people poll the IsPointerOverGameObject every Update to be more consistent, but I’m gonna swap to that method only when this breaks for me.