- Home /
Question by
ismettt088 · Sep 21, 2015 at 09:33 AM ·
touchtouch controlstouchestouching
Merging touches
Firstly, I am sorry about my English. I have 4 more scripts similar to this. Using one finger or using multiple fingers that far from eachother is not a problem, but when i touch 2+ finger very near they are merged(as there are a single touch). How can i solve this? Or how can i do this in another way? Thanks for answers.
using UnityEngine; using System.Collections;
public class Finger1 : MonoBehaviour {
public GameObject FingerDot1;
void Update()
{
if(Input.touchCount > 0)
{
TouchPhase phase0 = Input.GetTouch(0).phase;
Vector3 first = Camera.main.ScreenToWorldPoint(Input.GetTouch(0).position);
RaycastHit2D hit = Physics2D.Raycast(first,Vector2.zero);
switch(phase0)
{
case TouchPhase.Began:
FingerDot1.SetActive(true);
FingerDot1.transform.position =new Vector3(first.x,first.y,-15);
break;
case TouchPhase.Moved:
FingerDot1.transform.position =new Vector3(first.x,first.y,-15);
break;
case TouchPhase.Ended:
FingerDot1.SetActive(false);
break;
case TouchPhase.Canceled:
FingerDot1.SetActive(false);
break;
}
}
}
}
Comment
Your answer
Follow this Question
Related Questions
Touch.Phase Differences ? 2 Answers
Use touch to spawn a prefab 1 Answer
Check whether touch is held 0 Answers
Unusual multitouch behavior (Android) 3 Answers