private void DragOrPickUp() { var inputPosition = CurrentTouchPosition; if (draggingItem) { Vector3 tempNewPos = inputPosition + touchOffset; tempNewPos.z = -1; draggedPassenge.transform.position = tempNewPos; } else { trainManager.gameObject.SetActive(true); RaycastHit2D[] touches = Physics2D.RaycastAll(inputPosition, inputPosition, 0.5f); if (touches.Length > 0) { var hit = touches[0]; if (hit.transform != null && hit.transform.parent != null && hit.transform.parent.gameObject.tag == "passenge") { draggedPassenge = hit.transform.parent.gameObject; if (draggedPassenge != null && draggedPassenge.tag == "passenge") { trainManager.Show(); draggedPassenge.GetComponent <Passenge>().Cache(); draggedBlock = hit.transform.gameObject; originalPosition = draggedPassenge.transform.position; draggingItem = true; touchOffset = (Vector2)draggedPassenge.transform.position - inputPosition; } //draggedObject.transform.localScale = new Vector3(1.2f, 1.2f, 1.2f); } } } }