Error : The second touch should not work at all. How do I fix this error?,Error: The second touch should not work at all. How do I fix this error?
I have an item that should follow the touch of a finger. But when I touch the screen for the second time and remove the first finger, the object immediately goes to the second finger.
Please see the picture for a complete description:

Immediately write that these lines of code don't work :
- if(Input.touchCount == 1)
- Input.multiTouchEnabled = false;
This is my code:
 using System;
 using System.Collections;
 using System.Collections.Generic;
 using UnityEngine;
 using UnityEngine.EventSystems;
 
 public class DragDrop : MonoBehaviour
 {
  private Vector3 _mOffset;
  private float _mZCoord;
 
  private void OnMouseDown()
  {    
     _mZCoord = Camera.main.WorldToScreenPoint(gameObject.transform.position).z;
     _mOffset = gameObject.transform.position - GetMouseWorldPos();
  }
  private Vector3 GetMouseWorldPos()
  {
         var touchPointV2 = Input.GetTouch(0).position; 
         Vector3 touchPointV3 = new Vector3(touchPointV2.x, touchPointV2.y);
         touchPointV3.z = _mZCoord;
         return Camera.main.ScreenToWorldPoint(touchPointV3);
  }
 
  void OnMouseDrag()
  {
     Debug.Log("Run  -  OnMouseDrag");
     transform.position = GetMouseWorldPos() + _mOffset;
  }
 }
,I have an item that should follow the touch of a finger. But when I touch the screen for the second time and remove the first finger, the object immediately goes to the second finger.
Please see the picture for a complete description:

Immediately write that these lines of code don't work :
- if(Input.touchCount == 1)
- Input.multiTouchEnabled = false;
This is my code:
 using System;
 using System.Collections;
 using System.Collections.Generic;
 using UnityEngine;
 using UnityEngine.EventSystems;
 
 public class DragDrop : MonoBehaviour
 {
  private Vector3 _mOffset;
  private float _mZCoord;
 
  private void OnMouseDown()
  {    
     _mZCoord = Camera.main.WorldToScreenPoint(gameObject.transform.position).z;
     _mOffset = gameObject.transform.position - GetMouseWorldPos();
  }
  private Vector3 GetMouseWorldPos()
  {
         var touchPointV2 = Input.GetTouch(0).position; 
         Vector3 touchPointV3 = new Vector3(touchPointV2.x, touchPointV2.y);
         touchPointV3.z = _mZCoord;
         return Camera.main.ScreenToWorldPoint(touchPointV3);
  }
 
  void OnMouseDrag()
  {
     Debug.Log("Run  -  OnMouseDrag");
     transform.position = GetMouseWorldPos() + _mOffset;
  }
 }
Your answer
 
 
             Follow this Question
Related Questions
Error CS1026: Unexpected symbol ;, expecting ) 0 Answers
Simple cell-based game goes bonkers when clicked on the edge of the cell 0 Answers
i want to move object only when i swipe on screen not when touch, Unity 2d Android 0 Answers
When The Screen Is Touched Jump 0 Answers
Android Controls 1 Answer
 koobas.hobune.stream
koobas.hobune.stream 
                       
                
                       
			     
			 
                