Multi Touch Breaks on new Input System/Unity 2021/Device Simulator

Hello Everyone!

So, I noticed that the Multi-Touch was not working when testing on PC and following the course. I went to search for answers in the discussion, and saw that multiple people were having the same problem. I decided that I would then investigate what was happening. My findings were as follows:

Using up-to-date software does not work, if following the videos step by step. Enhanced Touch properly tracks the mouse, but also sees a second touch at 0f, 0f, 0f the same instant the mouse “drags” on the screen. Debugging on the console the Touch.activeTouches.Count shows 0 when not dragging, and 2 when dragging. A workaround is to not use the built-in device simulator, but to just use the Game Tab, as it works as expected.
Unity: 2021.3.6f1
Input System: 1.4.3
Device Simulator: Built-In on Game Tab.

Using up to date Unity and Rollback Input System does not work. It still sees the touch at 0f, 0f, 0f but does not register the mouse at all in Device Simulator. Works fine in Game Tab though.
Unity: 2021.3.6f1
Input System: 1.0.1
Device Simulator: Built-In on Game Tab.

Using similar versions from the video Works Correctly, which should be fine for those who just want to follow exactly as the videos. The problem is that this method is not future proof (but then again, when is any type of technology learning future proof?):
Unity: 2020.3.14f1
Input System: 1.0.1
Device Simulator: 3.0.3

However, when trying the same Unity and Device Simulator, but updating the Input System, it did not work at all:
Unity: 2020.3.14f1
Input System: 1.4.3 or 1.3.0
Device Simulator: 3.0.3

My conclusion is that there are several different factors that make this section not work as intended, and cannot be boiled down to one thing. A combination of Device Simulator version, Input System version, and Unity version can alter your experience. At the time of this writing, I have two possible solutions: (1) Follow the course using updated software to take advantage of new security features and learn more about Unity’s evolving codebase, and use the Game Tab to test on computer, or (2) Install the same (or close to the same) version of software in the video and follow along, just know that it is a bit outdated. Hopefully, someone much smarter than me can come up with a better solution!

Best,
J$

PS: This is just for testing Enhanced Touch / Multi Touch on PC, not for when building on mobile device.

3 Likes

Yes, we’ve encountered these issues, and I think it’s a bug in the interface between the input system and the input debugger (remember that we checked the “Mouse simulates Touch” button). Of course, we need this Mouse simulates Touch to use the mouse on the device simulator properly, so this presents a challenge.

In prior versions, I’ve suggested a filter for the touches

        foreach(Touch touch in Touch.activeTouches)
        {
            if(new Rect(0,0,Screen.width, Screen.height).Contains(touch.screenPosition))
            touchPosition += touch.screenPosition;
        }

and it has generally worked… At that time, the extra touches were happening in negative dimensions mostly (at least in my testing), but I haven’t checked this on the newer versions…

I did have one student say the solution didn’t work for him, but there was never an answer when I asked for more information. I suspect that this may have been a 0,0,0 touch, which the above filter would NOT catch (by design).

But if we set the filter to read:

        foreach(Touch touch in Touch.activeTouches)
        {
            if(new Rect(1,1,Screen.width-1, Screen.height-1).Contains(touch.screenPosition))
            touchPosition += touch.screenPosition;
        }

The filter should exclude a 0,0 touch.

1 Like

BallLauncherMultiTouch

I understand the if statement! Basically, if the touch is either outside the screen size (previous filter) or outside a 1 pixel border around the play area, then DON’T add the touch to the position. Unfortunately, both filters didn’t have any effect as the gif posted above =[ Since this doesn’t affect the actual build to device (only tested Android), I opted to just use Game Tab and forego the Simulator altogether. =[ Hopefully, some better documentation can come out at some point!

Oh, I think I just saw the issue, and why my filter wasn’t working (and now wonder why it worked in the first place!)

We’re adding all of the active touches, unless they fail the filter…
Then dividing by the number of active touches…
Meaning that even though 0,0 is filtered, the number of touches isn’t filtered.

Try this:

int effectiveTouchCount = 0;
foreach(Touch touch in Touch.activeTouches)
{
    if(new Rect(1,1,Screen.width-1, Screen.height-1).Contains(touch.ScreenPosition))
    {
         touchPosition +=touch.screenPosition;
         effectiveTouchCount++;
    }
}
touchPosition/=effectiveTouchCount;

This may still be an issue if the system registers a touch when you click outside of the screen… in which case it may be better to calculate the touchPosition and effectiveTouchCount at the beginning of the Update and then handle the logic of if the touch count is zero based on the effective touch count.

2 Likes

Hi all,

Using Unity 2021.3.5f1.

Just sharing my bug troubleshoot xp. When I started using the enhanced touch package it appears to have auto placed a Device Simulator Touchscreen into your Input debug as shown below.

image

If you also have the “simulate touch” checked as in previous lectures you’ll double up simulated inputs as shown below. This causes the input to go haywire.

image

Hope this helps someone!

6 Likes

You are a genious! Thank you!
That was the problem.
But I don’t know how I could disable “Simulated Touch Screen” permanently. Every time I play the game it shows up again. :cry:

I think it’s needed to properly use the mouse/device simulator.

Thank you. I just put it back to what it was before because of this issue. why would we need a multi touch for this game anyway? I appreciate the research on this and think it is useful to know this.

Trevor

I wondered much the same thing as the course was being developed. Truth be told, Nathan shows us how to use Multi Touch here for the sake of showing how to use Multi-Touch.

Thanks for finding this @skippy224! Worked for me too.

whoa, it worked , I am working on Unity 2021.3.23f1 And faced strange behaviour after updating Microsoft Visual Studio. Before it was working fine.

Using Unity 2022.3.42f1 (LTS) and Input System 1.7.0.

I had the same problem with “Simulated Touch Screen” being re-enabled after I re-opened the editor. To fix it, I did the following:

  1. Go to Edit > Project Settings > Player.
  2. Under “Other Settings”, find “Active Input Handling”.
  3. Make sure it’s set to “Input System Package (New)” - For me, it was set to “Both”.
  4. Restart the editor.

Now “Simulated Touch Screen” remained disabled across editor restarts.

Privacy & Terms