Touch Joystick not working properly with multiple touches
I have a VirtualJoystick script that handles a joystick input. I used Input.mousePosition, Input.MouseButtonDown and Input.MouseButton to grab the touch position, set a pointA when the touch first starts (origin of the joystick), and constantly update a pointB while the touch continues. I included what those _inputManager methods return.
private void UpdateTouch()
{
touchPosition = _inputManager.GetPointerPosition(); //Input.mousePosition()
// Origin of the joystick
if (_inputManager.GetPointerButtonDown()) //Input.MouseButtonDown(0)
{
pointA = _inputManager.ScreenToWorldPoint(touchPosition); //Camera.main.ScreenToWorldPoint(new Vector3(touchPosition.x, touchPosition.y, Camera.main.transform.position.z));
}
// Set the position of the joystick knob while being dragged
if (_inputManager.GetPointerButtonHeld()) //Input.MouseButton(0)
{
touch = true;
pointB = _inputManager.ScreenToWorldPoint(touchPosition); //Camera.main.ScreenToWorldPoint(new Vector3(touchPosition.x, touchPosition.y, Camera.main.transform.position.z));
}
else
{
touch = false;
}
}
My issue is, while joystick is being controlled with a finger, when a second finger is on the screen, the pointB is switched to that (pointA remains the same). I only want the finger on the left half side of the screen to control the joystick. How can I do that?
Your answer
Follow this Question
Related Questions
OnScreen-Stick that moves to the position touched 0 Answers
Disabling aiming towards Joystick on first input. 0 Answers
how to do some stuff from both swipe and tap 0 Answers
Joystick freezes when new scene is loaded,Joystick freezes when loading a new scene 0 Answers
Brackeys's Making a Video Game going mobile and collision issue 0 Answers