Esempio n. 1
0
    // referenceTransform controls the 'perspective' of the rotation.
    // pass a gameObjects own transform to rotate that object up, down, left, right in the world.
    // pass a camera's transform to rotate up, down, left, right from the perspective of that camera.
    public void StartArc(Transform referenceTransform, ArcType arcDirection, Vector3 _arcPoint, AnimCurve.MotionType motionType)
    {
        arcPoint = _arcPoint;
        animCurve.currentMotionType = motionType;
        // assumes camera is always aligned with one axis and 0 on the others.
        // StartMovement() and FixedUpdate() implement an arc between one axis and the other.
        switch (arcDirection)
        {
        case ArcType.Up:
            rotationAxis = referenceTransform.right;
            rotAngle     = 90.0f;
            break;

        case ArcType.Down:
            rotationAxis = referenceTransform.right;
            rotAngle     = -90.0f;
            break;

        case ArcType.Left:
            rotationAxis = referenceTransform.up;
            rotAngle     = 90.0f;
            break;

        case ArcType.Right:
            rotationAxis = referenceTransform.up;
            rotAngle     = -90.0f;
            break;
        }
        angleLeftToRotate = rotAngle;
        Transform t = transform;

        t.RotateAround(arcPoint, rotationAxis, rotAngle);
        targetEuler = t.rotation.eulerAngles;
        targetPos   = t.position;
        t.RotateAround(arcPoint, rotationAxis, -rotAngle);
        animationState = AnimationState.Moving;
    }
Esempio n. 2
0
 public static void RotateCameras(Transform relativeTransform, Rotator.ArcType arcType, AnimCurve.MotionType motionType)
 {
     if (Instance == null)
     {
         return;
     }
     foreach (CamAnimator camAnimator in Instance.cameraAnimators)
     {
         camAnimator?.rotator.StartArc(relativeTransform, arcType, Vector3.zero, motionType);
     }
 }