Script errors

Im writing VSC with teamviewer from my phone, so I couldn’t press ctrl+. on touchscreen, so I write it manually. Is there anyway to fix it?

Thank you.

It looks like Unity itself is recognizing the script (or you’d have error messages that wouldn’t let you run the game in the 2nd screenshot. Sometimes Visual Studio Code doesn’t keep up with the changes. In Unity Edit/Preferences/External Tools, try regenerating the project files. Also make sure your plugins in Code are up to date as well as the Visual Studio Code plugin in the Package Manager.

When I’m not on my phone, I’ll post a quick and dirty solution to the Screen Position out of Frustrum error (it’s actually a bug in the Unity Device Simulator, and can be fixed by discarding any touches that are not within the screen’s area before running calculations.

For the Screen Position out of frustrum view, this is because in the simulator, sometimes, there are “false” hits outside of the screen bounds. We can alleviate this issue in PlayerMovement.ProcessInput, right after getting the touch position, add this little snippet:

            if (!Screen.safeArea.Contains(touchPosition))
            {
                movementDirection = Vector3.zero;
                return;
            }

This will basically disregard any false touches.
In the final built game, this bug does not appear. It’s a bug in the Device Simulator.

This topic was automatically closed 20 days after the last reply. New replies are no longer allowed.

Privacy & Terms