private void CheckActionOnCube() { if (currentState == EngagedState.Idle) { if (CheckMainInputBegan) { Ray ray = cam.ScreenPointToRay(GetMainInputPosition); if (Physics.Raycast(ray, out var hit, 100f, cubeletLayer)) { currentState = EngagedState.OnCube; cubeletFromAction = hit.transform; cubeActionPoint = hit.point; screenActionPoint = cam.ScreenToViewportPoint(GetMainInputPosition); catcher.position = hit.point; catcher.forward = hit.normal; } } } if (currentState != EngagedState.OnCube) { return; } if (CheckMainInputOn) { if (!(Vector2.Distance(screenActionPoint, cam.ScreenToViewportPoint(GetMainInputPosition)) > (0.3f / cameraMovementManager.ZoomDistance))) { return; } Ray ray = cam.ScreenPointToRay(GetMainInputPosition); if (Physics.Raycast(ray, out var hit, 100f, actionCatcherLayer)) { Vector3 localDir = catcher.InverseTransformDirection((hit.point - cubeActionPoint).normalized); Vector3 chosenDir; if (Mathf.Abs(localDir.x) > Mathf.Abs(localDir.y)) { chosenDir = catcher.up * ((localDir.x > 0f) ? 1f : -1f); } else { chosenDir = catcher.right * ((localDir.y > 0f) ? -1f : 1f); } EvaluateDirectionToRotAxis(chosenDir, out Axis rotAxis, out bool clockwise); cubeManager.SetRotation(cubeletFromAction, rotAxis, clockwise); } currentState = EngagedState.Idle; } else { currentState = EngagedState.Idle; } }
private void CheckCameraRotation() { if (CheckMainInputOn) { if (CheckMainInputBegan && InputNotOverMenu) { currentState = EngagedState.RotatingCam; } } else { currentState = EngagedState.Idle; } if (currentState != EngagedState.RotatingCam) { return; } cameraMovementManager.RotateAroundCenter(GetMainInputMoveDelta); }