Nez
Nez copied to clipboard
Add ability to simulate VirtualInput activation
This changes the four VirtualInput classes to include a Simulate(...)
method that allows (you guessed it) simulating an input.
The implementation uses the Update()
method to keep the input activated for one frame, with the help of a simulationStep
counter.
This may be pretty hacky, so I'm open to reimplementing it in a cleaner way if the maintainers so desire.
Why not just subclass a custom Node? you could implement the same functionality.
Yeah, @redthing1 may be right on this one. Now that I see the code it’s a bit more intrusive than my initial thoughts about it ;) Maybe instead swap to a subclass for each: SimulatedVirtualAxis, SimulatedVirtualButton, etc.
Ya, I did exactly this in my project. If you want the code let me know, but it's pretty simple and straightforward to implement yourself.
I guessed as much because to be honest I wasn't satisfied with it myself. @redthing1 Yes I would like to see the code please. I'll open a new PR once I get the chance (tomorrow is a Monday™!)
Very very simple, here's my virtual joystick:
public class LogicJoystick : Nez.VirtualJoystick.Node {
public override Vector2 Value => LogicValue;
public Vector2 LogicValue { get; set; }
}