탱크 팔로우 카메라

System.Collections 사용;

System.Collections.Generic 사용;

UnityEngine 사용;

 

공개 클래스 Camera_Follow_Zoom : MonoBehaviour {

    공개 변환 대상;

    공개 플로트 distanceUp = 5f;

    공개 플로트 distanceAway = 5f;

    public float smooth = 2f;//위치 부드러운 이동 값

    공개 플로트 camDepthSmooth = 2f;

    // 초기화에 사용

    무효 시작 () {

}

// 업데이트는 프레임당 한 번 호출됩니다.

무효 업데이트()

    {

        // 마우스 축은 카메라의 거리를 제어합니다.

        if ((Input.mouseScrollDelta.y < 0 && Camera.main.fieldOfView >= 3) || Input.mouseScrollDelta.y > 0 && Camera.main.fieldOfView <= 80)

        {

            Camera.main.fieldOfView += Input.mouseScrollDelta.y * camDepthSmooth * Time.deltaTime;

        }

 

    }

 

    무효 LateUpdate()

    {

        // 카메라 위치

        Vector3 disPos = target.position + Vector3.up * distanceUp - target.forward * distanceAway;

        transform.position = Vector3.Lerp(transform.position, disPos, Time.deltaTime * smooth);

        // 카메라 앵글

        transform.LookAt(target.position);

    }

}

Supongo que te gusta

Origin blog.csdn.net/qq_23231303/article/details/77998456
Recomendado
Clasificación