после поиска решения. Я все еще не могу понять, почему мой мультитач-скрипт в единстве не работает. Это мой код. И прежде чем спросить: все переменные существуют.Не удается получить мультитач для работы в Unity3D
void Update()
{
if (Input.touchCount > 0)
{
for (i = 0; i < Input.touchCount; i++)
{
if (Input.GetTouch(i).phase != TouchPhase.Ended)
{
hit = Physics2D.Raycast(Camera.main.ScreenToWorldPoint(Input.GetTouch(0).position), Vector2.zero);
if (hit.collider != null && hit.transform.gameObject.tag == "Links")
{
cannon.GetComponent<Rigidbody2D>().MovePosition(cannon.GetComponent<Rigidbody2D>().position + new Vector2(-0.1f, 0) * Time.deltaTime * moveSpeed);
}
else if (hit.collider != null && hit.transform.gameObject.tag == "Rechts")
{
cannon.GetComponent<Rigidbody2D>().MovePosition(cannon.GetComponent<Rigidbody2D>().position + new Vector2(0.1f, 0) * Time.deltaTime * moveSpeed);
}
}
if (Input.GetTouch(i).phase == TouchPhase.Began)
{
hit = Physics2D.Raycast(Camera.main.ScreenToWorldPoint(Input.GetTouch(0).position), Vector2.zero);
if (hit.collider != null && hit.transform.gameObject.tag == "Fire")
{
clone = Instantiate(projectile, cannon.transform.position + new Vector3(0, 1.3f, 0), transform.rotation) as Rigidbody2D;
clone.velocity = new Vector2(0, speed);
}
}
}
}
}
Он регистрирует только один вход за раз. Да, мой телефон поддерживает мультитач. Я буду признателен за любую помощь.
Просто добавьте Debug.Log для отладки кода. ... вы быстро найдете проблему – Fattie