// Input Methods public void InputLoop() { if (selectionTimer > 0) { selectionTimer -= Time.deltaTime; } if (Input.GetMouseButtonDown(1)) { Unselect(); } if (selectionTimer <= 0) { Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition); if (Input.GetMouseButton(0) && selected != null) { isMovementBeingCharged = true; RaycastHit hit; if (Physics.Raycast(ray, out hit)) { selected.LineRenderer().SetPosition(1, new Vector3(hit.point.x, hit.point.y, 0)); } } else if (selected != null && isMovementBeingCharged && Input.GetMouseButtonUp(0)) { RaycastHit hit; float distance; if (Physics.Raycast(ray, out hit)) { Vector3 hitPos = new Vector3(hit.point.x, hit.point.y, 0); distance = Vector3.Distance(selected.transform.position, hitPos); selected.AddForce((hitPos - selected.transform.position).normalized * distance * Data.instance.PushStrength()); } selectionTimer = Data.instance.SelectionCooldown(); movesLeft--; if (movesLeft > 0) { Party(); } else { End(); } } else { isMovementBeingCharged = false; } } }