ReadMe.md

    游戏控制的摄像机

    了解如何激活和切换不同的视角。

    定义引用的Actor

    
    	UPROPERTY(EditAnywhere)
    	AActor* CameraOne;
    
    	UPROPERTY(EditAnywhere)
    	AActor* CameraTwo;
    
    	float TimeToNextCameraChange;

    切换视角

    #include "Kismet/GameplayStatics.h"
    
    void ACameraDirector::Tick(float DeltaTime)
    {
    	Super::Tick(DeltaTime);
    
    	const float TimeBetweenCameraChanges = 2.0f;
    	const float SmoothBlendTime = 0.75f;
    
    	TimeToNextCameraChange -= DeltaTime;
    
    	if (TimeToNextCameraChange <= 0.0f) {
    
    		TimeToNextCameraChange += TimeBetweenCameraChanges;
    
    		APlayerController* PlayController = UGameplayStatics::GetPlayerController(this, 0);
    		if (PlayController) {
    
    			if (PlayController->GetViewTarget() != CameraOne && CameraOne != nullptr) {
    				PlayController->SetViewTarget(CameraOne);
    			}
    			else if (PlayController->GetViewTarget() != CameraTwo && CameraTwo != nullptr) {
    				PlayController->SetViewTargetWithBlend(CameraTwo, SmoothBlendTime);
    			}
    		}
    	}
    }

    Result

    AutoCamera

    Reference

    1. AutoCamera - https://docs.unrealengine.com/4.26/zh-CN/ProgrammingAndScripting/ProgrammingWithCPP/CPPTutorials/AutoCamera/

    项目简介

    自动切换像机

    发行版本

    当前项目没有发行版本

    贡献者 1

    wblong_cs @mrbaolong

    开发语言

    • C++ 60.1 %
    • C# 37.6 %
    • C 2.2 %