void Update() { if (Input.touchCount <= 0 && !Input.GetMouseButton(0)) { if (touched && !changingDirection) { if (customDirection.x + 1 < 0.01) { manager.RemoveArrow(this); return; //if (spriteRenderer.enabled) //{ // manager.RemoveArrow(this); // spriteRenderer.enabled = false; // this.alwaysTrigger = this.useCustomDirection = false; // touched = true; // return; //} //this.alwaysTrigger = this.useCustomDirection = true; //spriteRenderer.enabled = true; } customDirection = Quaternion.Euler(0, 0, -90) * customDirection; customDirection = new Vector2(Mathf.RoundToInt(customDirection.x), Mathf.RoundToInt(customDirection.y)); spriteRenderer.transform.Rotate(new Vector3(0, 0, -90)); } touched = false; changingDirection = false; return; } if (!Input.GetMouseButtonDown(0) && (Input.touchCount == 0 || (Input.touchCount > 0 && Input.GetTouch(0).tapCount > 1))) { return; } Vector2 touchPosition = manager.snap.Snap(Camera.main.ScreenToWorldPoint(Input.GetMouseButtonDown(0) ? (Vector2)Input.mousePosition : Input.GetTouch(0).position)); Vector2 gridPosition = grid.ConvertWorldToGrid(touchPosition); if (gridPosition.x == this.xInGrid && gridPosition.y == this.yInGrid && !touched) { this.swipe.AllowSwipe(); touched = true; } }