- Home /
Simultaneous touch inputs do not always work
In our game, we want the player to reliably tap multiple GameObjects to change their color. Currently it works most of the time. But sometimes it is only registering one of the touch inputs instead of both. We have included a Debug.Log to check the touch count, when we have the problem, only 1 touch is registered even though we are tapping two game objects. The one that does register changes color without a problem but the other one does nothing. Again, this only happens sometimes but is a significant issue to the game play.
void Update () {
for (int i = 0; i < Input.touchCount; ++i)
{
if (Input.GetTouch(i).phase == TouchPhase.Began)
{
RaycastHit2D raycastHit = Physics2D.Raycast(Camera.main.ScreenToWorldPoint((Input.GetTouch(i).position)), Vector2.zero);
if (raycastHit.collider != null)
{
Debug.Log("Input Manager: " + raycastHit.collider.gameObject.name + "\n Touch: " + i.ToString() +" of " + Input.touchCount.ToString());
}
}
Comment
Your answer
Follow this Question
Related Questions
Multitouch Hold and Move 0 Answers
Touch Inputs Not Allowing Mutiple Presses 1 Answer
Simultaneous button presses 2 Answers