Example #1
0
        private void HandleCameraRotation()
        {
            if (Input.GetMouseButtonDown(MouseButtons.LEFT))
            {
                pitch = transform.eulerAngles.x;
                yaw   = transform.eulerAngles.y;
            }

            if (Input.GetMouseButton(MouseButtons.LEFT) && Input.GetKey(KeyCode.LeftAlt))
            {
                float yawDelta   = RotationSpeedAdjusted * Input.GetAxis("Mouse X");
                float pitchDelta = -RotationSpeedAdjusted *Input.GetAxis("Mouse Y");

                IPLESelectable pleSelectable = levelEditor.gridController.GetFirstSelectedTile() ?? spawnMenu.SelectedItem;
                if (!pleSelectable.IsNull() && pleSelectable.IsFocused)
                {
                    Transform target = pleSelectable.GetTransform;
                    transform.LookAt(target);
                    transform.RotateAround(target.position, transform.right, pitchDelta);
                    transform.RotateAround(target.position, transform.up, yawDelta);
                }
                else
                {
                    yaw   += yawDelta;
                    pitch += pitchDelta;
                    transform.eulerAngles = new Vector3(pitch, yaw, 0.0f);
                }
            }
        }
Example #2
0
        private void SetupRecenter()
        {
            IPLESelectable pleSelectable = levelEditor.gridController.GetFirstSelectedTile() ?? spawnMenu.SelectedItem;

            if (!pleSelectable.IsNull())
            {
                Recenter(pleSelectable);
            }
        }
Example #3
0
        private void Recenter(IPLESelectable pleSelectable)
        {
            Timing.KillCoroutines(CoroutineName);
            pleSelectable.Focus();
            Transform target = pleSelectable.GetTransform;

            startPosition  = transform.position;
            startRotation  = transform.rotation;
            targetPosition = target.position - Vector3.ClampMagnitude(target.position - startPosition, maxDistanceOnRecenter);
            targetRotation = Quaternion.LookRotation(target.position - startPosition, Vector3.up);
            recenterAnim.Animate(CoroutineName);
        }