Ejemplo n.º 1
0
    void Follow()
    {
        if (target == null)
        {
            return;
        }
        InputFrame input = InputFrame.GetFrame();

        deltaX += input.h * angularSpeedX * Time.deltaTime;
        deltaY += input.v * angularSpeedY * Time.deltaTime;

        deltaX = Mathf.Clamp(ClampAngle(deltaX), -limitX, limitX);
        deltaY = Mathf.Clamp(ClampAngle(deltaY), -limitY, limitY);

        Quaternion rot            = Quaternion.Euler(new Vector3(-deltaY, deltaX, 0f));
        Vector3    dist           = new Vector3(0f, 0f, -currentDistanceAway) + Vector3.right * shiftX + Vector3.up * shiftY;
        Vector3    targetPosition = rot * dist + target.position;

        transform.rotation = rot;
        transform.position = targetPosition;
    }