How can i move just one object ?
Hey, I want to create an android game in where you can open doors by swipe right and left,but when i swipe all the objects with this script moves.How can i move the doors one by one?
void Update() { if (Input.touchCount > 0) { Touch touch = Input.GetTouch(0); if (touch.phase == TouchPhase.Began) { StartTime = Time.time; StartPoint = touch.position; } else if (touch.phase == TouchPhase.Ended) { EndTime = Time.time; EndPoint = touch.position; SwipeDistance = (EndPoint - StartPoint).magnitude; if (swipeTime < MaxTime && SwipeDistance > MinSwipeDistance) { swipe(); } }
}
}
void swipe()
{
Vector2 distance = EndPoint - StartPoint;
if (hit.transform.gameObject.tag == "UsaLaStanga" && distance.x < 0)
{
Debug.Log("LefttSwipe");
rb.AddForce(-100, 0, 0);
}
}
}
Comment