I’m trying to write some unit tests in gdUnit and I’d like to emulate user input, which I handle on my character using unhandled input function. I’ve tried using Input but this I presume isn’t treated as an unhandled input under the hood. Is there a way to generate unhandled input without user input?
I think this is probably my bad layout - as I have Input.get_vector() under my unhandled input which strikes me as maybe not a correct approach. Open to suggestions
I use these lines of code to emulate the “pause” action being pressed when the player disconnects a controller. The game checks whether the player presses the “pause” action in the _unhandled_input(event) function. I believe this should work for you as well.
First, create a new action event with InputEventAction.new() and assign it to a temporary variable; something like var emulated_action = InputEventAction.new(). Next, set this action’s action property to the corresponding action as String and the pressed property to true. Finally, parse the event by calling Input.parse_input_event(emulated_action).