UE4 使用藍圖或C++切換攝像機視角


一、使用藍圖切換視角

1.打開一個空項目,在場景中拖入兩個或若干個CineCameraActor。

2.在尋找CineCameraActor時,有多種方法可供選擇,第一種直接在藍圖關卡中創建物體的引用。

或者創建CineCameraActor的變量,再指定攝像機。

第二種通過物體的名字選擇相機。

第三種通過尋找物體的Tag指定相機。在相機的Details面板里,找到Actor分類下的Tags屬性,添加一個tag。

 

二、使用C++切換攝像機視角

 

APlayerController* OurPlayerController = UGameplayStatics::GetPlayerController(this, 0);
    if (OurPlayerController)
    {
        if ((OurPlayerController->GetViewTarget() != CameraOne) && (CameraOne != nullptr))
        {
            // 立即切換到相機1。
            OurPlayerController->SetViewTarget(CameraOne);
        }
        else if ((OurPlayerController->GetViewTarget() != CameraTwo) && (CameraTwo != nullptr))
        {
            // 平滑地混合到相機2。
            OurPlayerController->SetViewTargetWithBlend(CameraTwo, SmoothBlendTime);
        }
    }

 

 

 

代碼參考自http://api.unrealengine.com/CHN/Programming/Tutorials/AutoCamera/2/index.html

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM