Skip to content

Conversation

@fuzzypixelz
Copy link

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.

@redthing1
Copy link
Collaborator

Why not just subclass a custom Node? you could implement the same functionality.

@prime31
Copy link
Owner

prime31 commented Sep 19, 2021

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.

@redthing1
Copy link
Collaborator

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.

@fuzzypixelz
Copy link
Author

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™!)

@redthing1
Copy link
Collaborator

Very very simple, here's my virtual joystick:

public class LogicJoystick : Nez.VirtualJoystick.Node {
            public override Vector2 Value => LogicValue;

            public Vector2 LogicValue { get; set; }
        }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants