L
L
LittleBob2021-10-18 10:14:29
Unity
LittleBob, 2021-10-18 10:14:29

How to register only one OnMouseDrag in Unity?

There is an OnMouseDrag method, it registers clicks on the screen. The problem is that I use this method on Android, and if I press with several fingers, then bugs occur. Is it possible to fix this so that only the first tap on the screen is registered?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
mustGamedev, 2021-10-18
@LittleBob

The android for the unit has its own methods of tapping the screen.
Here is the documentation on touches (clicks on the screen): https://docs.unity3d.com/ScriptReference/Touch.html
What you need to detect is only one tap on the screen, because in your case the engine registers all fingers on the screen, so it gives an error .
In Update() write something like this:

if (Input.touchCount == 1)
{
 выполнить после 1 нажатия
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question