question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Add virtual joystick input

See original GitHub issue

Visually, it should look similar to this.

First, the API design should be proposed based on what information we want to obtain from the joystick. Presumably, we want a vector from the joystick center to where the player pointer (finger / cursor) is, when the joystick is being pressed. Using the vector we can obtain both the direction and length (magnitude that we can use to estimate force).

Edit: functionality is there apart from force, which needs to be calculated and obtained via vector before this is closed.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:6 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
AlmasBcommented, Apr 13, 2020

Yes, sounds good, you should be able to use the pressedProperty() of the Parent (which VirtualJoystick is) to see if the foreground circle should be moved to where player input (cursor or finger) is.

Maybe something like this (I call foreground inner for conciseness)

innerCircle.translateXProperty().bind(
    Bindings.when(pressedProperty()).then(input.mouseUIXProperty()).otherwise(center.x)
);

// same for y

Not sure how whether the above will work for multi touch screens (e.g. on mobile), but it’s a start.

0reactions
lilbigmouthcommented, May 22, 2020

Good stuff! 😃

Read more comments on GitHub >

github_iconTop Results From Across the Web

Mobile Virtual Joystick Movement with Unity's Input System
My game is using the Unity Input System package, which has a pair of very easy-to-use scripts for on-screen touch input. If you...
Read more >
Create two virtual joysticks (touch) with the new input system
So, as the title says, I'm trying to create two virtual joysticks (one for aim, one for move). I have noticed that there's...
Read more >
On-screen Controls | Input System | 1.0.2 - Unity - Manual
For example, if one on-screen button references <Gamepad>/buttonSouth and another on-screen button references <Keyboard>/a , the Input System ...
Read more >
How To Add Multi-touch and Virtual Joystick Controls
Create a new object; Make it a child of obj_ui_parent; Define the input(_touch_id, _touch_x, _touch_y) function; Make that function do whatever ...
Read more >
Advanced Features - JoyToKey
Virtual joysticks (a.k.a. SHIFT-key function). Assume your joystick has only 6 buttons, but you want to assign 10 different key inputs to your...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found