美文网首页
2018-10-17 镜头平滑切换

2018-10-17 镜头平滑切换

作者: constantine丶 | 来源:发表于2018-10-17 18:39 被阅读0次

镜头控制相关

#include "Kismet/GameplayStatics.h"

GameplayStatics头文件让我们可以访问一些有用的通用函数
如 UGameplayStatics::GetPlayerController(this, 0) 得到玩家控制

    const float TimeBetweenCameraChanges = 2.0f;
    const float SmoothBlendTime = 0.75f;
    TimeToNextCameraChange -= DeltaTime;
    if (TimeToNextCameraChange <= 0.0f)
    {
        TimeToNextCameraChange += TimeBetweenCameraChanges;

        //Find the actor that handles control for the local player.
        APlayerController* OurPlayerController = UGameplayStatics::GetPlayerController(this, 0);
        if (OurPlayerController)
        {
            if ((OurPlayerController->GetViewTarget() != CameraOne) && (CameraOne != nullptr))
            {
                //Cut instantly to camera one.
                OurPlayerController->SetViewTarget(CameraOne);
            }
            else if ((OurPlayerController->GetViewTarget() != CameraTwo) && (CameraTwo != nullptr))
            {
                //Blend smoothly to camera two.
                OurPlayerController->SetViewTargetWithBlend(CameraTwo, SmoothBlendTime);
            }
        }
    }

相关文章

网友评论

      本文标题:2018-10-17 镜头平滑切换

      本文链接:https://www.haomeiwen.com/subject/mxwrzftx.html