// Fill out your copyright notice in the Description page of Project Settings.
#pragma once
#include "CoreMinimal.h"
#include "GameFramework/Actor.h"
#include "CollectActor.generated.h"
UCLASS()
class BATTERYRETRIEVER_API ACollectActor : public AActor
{
GENERATED_BODY()
public:
// Sets default values for this actor's properties
ACollectActor();
//静态网格
UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = "Properties")
class UStaticMeshComponent* StaticMesh;
protected:
// Called when the game starts or when spawned
virtual void BeginPlay() override;
//是否被拾取
bool bIsActive;
public:
// Called every frame
virtual void Tick(float DeltaTime) override;
//返回拾取的物体
FORCEINLINE class UStaticMeshComponent* GetMesh() { return StaticMesh; }
//返回拾取的状态
UFUNCTION(BlueprintPure, Category = "Pickup")
bool IsActive();
//改变拾取的状态
UFUNCTION(BlueprintCallable, Category = "Pickup")
void SetActive(bool NewPickupState);
};
// Fill out your copyright notice in the Description page of Project Settings.
#include "CollectActor.h"
#include "Components/StaticMeshComponent.h"
// Sets default values
ACollectActor::ACollectActor()
{
// Set this actor to call Tick() every frame. You can turn this off to improve performance if you don't need it.
PrimaryActorTick.bCanEverTick = true;
StaticMesh = CreateDefaultSubobject<UStaticMeshComponent>(TEXT("StaticMesh"));
RootComponent = StaticMesh;
}
// Called when the game starts or when spawned
void ACollectActor::BeginPlay()
{
Super::BeginPlay();
}
// Called every frame
void ACollectActor::Tick(float DeltaTime)
{
Super::Tick(DeltaTime);
}
bool ACollectActor::IsActive()
{
return bIsActive;
}
void ACollectActor::SetActive(bool NewPickupState)
{
bIsActive = NewPickupState;
}
// Fill out your copyright notice in the Description page of Project Settings.
#pragma once
#include "CoreMinimal.h"
#include "CollectActor.h"
#include "BatteryCollectActor.generated.h"
/**
*
*/
UCLASS()
class BATTERYRETRIEVER_API ABatteryCollectActor : public ACollectActor
{
GENERATED_BODY()
public:
ABatteryCollectActor();
protected:
};
// Fill out your copyright notice in the Description page of Project Settings.
#include "BatteryCollectActor.h"
ABatteryCollectActor::ABatteryCollectActor()
{
//设置物理状态
GetMesh()->SetSimulatePhysics(true);
}
UPROPERTY(VisibleAnywhere, BlueprintReadOnly)
class UBoxComponent* SpawnBox;
//定义电池生成变量
UPROPERTY(EditAnywhere, Category = "Spawn Volume")
TSubclassOf<class ACollectActor>SpawnClass;
FTimerHandle TimerHandle;
//最小延迟
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Spawn Volume")
float MinDelayTimer;
//最大延迟
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Spawn Volume")
float MaxDelayTimer;
//真实的延迟
float SpawnDelay;
//获取随机点
UFUNCTION(BlueprintPure, Category = "Spawn Volume")
FVector GetSpawnRandomLocation();
//管理一个新的触发拾取
void SpawnPickup();
FVector ASpawnVolume::GetSpawnRandomLocation()
{
FVector SpawnOrigin = SpawnBox->Bounds.Origin;
FVector SpawnExtent = SpawnBox->Bounds.BoxExtent;
return UKismetMathLibrary::RandomPointInBoundingBox(SpawnOrigin, SpawnExtent);
}
void ASpawnVolume::SpawnPickup()
{
if (SpawnClass != NULL)
{
UWorld* World = GetWorld();
if (World)
{
//设置触发参数
FActorSpawnParameters SpawnParams;
SpawnParams.Owner = this;
SpawnParams.Instigator = GetInstigator();
//获取触发的随机位置
FVector SpawnLocation = GetSpawnRandomLocation();
//获取触发物体的随机旋转
FRotator SpawnRotation;
SpawnRotation.Yaw = FMath::FRand() * 360.f;
SpawnRotation.Pitch = FMath::FRand() * 360.f;
SpawnRotation.Roll = FMath::FRand() * 360.f;
//生成电池
ACollectActor* SpawnPickup = World->SpawnActor<ACollectActor>(SpawnClass, SpawnLocation,
SpawnRotation, SpawnParams);
//真实延迟时间范围
SpawnDelay = FMath::FRandRange(MinDelayTimer, MaxDelayTimer);
//定时器生成电池
GetWorld()->GetTimerManager().SetTimer(TimerHandle,this, &ASpawnVolume::SpawnPickup, SpawnDelay, false);
}
}
}
// Called when the game starts or when spawned
void ASpawnVolume::BeginPlay()
{
Super::BeginPlay();
//真实延迟时间范围
SpawnDelay = FMath::FRandRange(MinDelayTimer, MaxDelayTimer);
//定时器生成电池
GetWorld()->GetTimerManager().SetTimer(TimerHandle, this, &ASpawnVolume::SpawnPickup, SpawnDelay, false);
}
// Fill out your copyright notice in the Description page of Project Settings.
#pragma once
#include "CoreMinimal.h"
#include "GameFramework/Actor.h"
#include "SpawnVolume.generated.h"
UCLASS()
class BATTERYRETRIEVER_API ASpawnVolume : public AActor
{
GENERATED_BODY()
public:
// Sets default values for this actor's properties
ASpawnVolume();
UPROPERTY(VisibleAnywhere, BlueprintReadOnly)
class UBoxComponent* SpawnBox;
//定义电池生成变量
UPROPERTY(EditAnywhere, Category = "Spawn Volume")
TSubclassOf<class ACollectActor>SpawnClass;
FTimerHandle TimerHandle;
//最小延迟
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Spawn Volume")
float MinDelayTimer;
//最大延迟
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Spawn Volume")
float MaxDelayTimer;
//真实的延迟
float SpawnDelay;
protected:
// Called when the game starts or when spawned
virtual void BeginPlay() override;
public:
// Called every frame
virtual void Tick(float DeltaTime) override;
//获取随机点
UFUNCTION(BlueprintPure, Category = "Spawn Volume")
FVector GetSpawnRandomLocation();
//管理一个新的触发拾取
void SpawnPickup();
};
// Fill out your copyright notice in the Description page of Project Settings.
#include "SpawnVolume.h"
#include "Components/BoxComponent.h"
#include "Kismet/KismetMathLibrary.h"
#include "../MyActors/CollectActor.h"
#include "Engine/Engine.h"
// Sets default values
ASpawnVolume::ASpawnVolume()
{
// Set this actor to call Tick() every frame. You can turn this off to improve performance if you don't need it.
PrimaryActorTick.bCanEverTick = true;
SpawnBox = CreateDefaultSubobject<UBoxComponent>(TEXT("SpawnBox"));
RootComponent = SpawnBox;
//延迟区间
MinDelayTimer = 1.f;
MaxDelayTimer = 4.f;
}
// Called when the game starts or when spawned
void ASpawnVolume::BeginPlay()
{
Super::BeginPlay();
//真实延迟时间范围
SpawnDelay = FMath::FRandRange(MinDelayTimer, MaxDelayTimer);
//定时器生成电池
GetWorld()->GetTimerManager().SetTimer(TimerHandle, this, &ASpawnVolume::SpawnPickup, SpawnDelay, false);
}
// Called every frame
void ASpawnVolume::Tick(float DeltaTime)
{
Super::Tick(DeltaTime);
}
FVector ASpawnVolume::GetSpawnRandomLocation()
{
FVector SpawnOrigin = SpawnBox->Bounds.Origin;
FVector SpawnExtent = SpawnBox->Bounds.BoxExtent;
FVector OriginPoint = SpawnBox->GetComponentLocation();
return UKismetMathLibrary::RandomPointInBoundingBox(SpawnOrigin, SpawnExtent);
}
void ASpawnVolume::SpawnPickup()
{
if (SpawnClass!=NULL)
{
UWorld* World = GetWorld();
if (World)
{
//设置触发参数
FActorSpawnParameters SpawnParams;
SpawnParams.Owner = this;
SpawnParams.Instigator = GetInstigator();
//获取触发的随机位置
FVector SpawnLocation = GetSpawnRandomLocation();
//获取触发物体的随机旋转
FRotator SpawnRotation;
SpawnRotation.Yaw = FMath::FRand() * 360.f;
SpawnRotation.Pitch = FMath::FRand() * 360.f;
SpawnRotation.Roll = FMath::FRand() * 360.f;
//生成电池
ACollectActor* const SpawnPickup = World->SpawnActor<ACollectActor>(SpawnClass, SpawnLocation,
SpawnRotation, SpawnParams);
//真实延迟时间范围
SpawnDelay = FMath::FRandRange(MinDelayTimer, MaxDelayTimer);
//定时器生成电池
GetWorld()->GetTimerManager().SetTimer(TimerHandle,this, &ASpawnVolume::SpawnPickup, SpawnDelay, false);
}
}
}
//当物体被收集时调用此方法
UFUNCTION(BlueprintNativeEvent,BlueprintCallable)
void WasCollected();
virtual void WasCollected_Implementation();
void ACollectActor::WasCollected_Implementation()
{
FString PickupDebug = GetName();
UE_LOG(LogTemp, Warning, TEXT("你收集了%s"), *PickupDebug);
}
void ABatteryCollectActor::WasCollected_Implementation()
{
Super::WasCollected_Implementation();
//销毁电池
Destroy();
}
//球形检测
UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = "Collection")
class USphereComponent* CollectionSphere;
//收集电池处理函数
UFUNCTION(BlueprintCallable, Category = "Pickups")
void CollectPickups();
//创建球形组件
CollectionSphere = CreateDefaultSubobject<USphereComponent>(TEXT("CollectionSphere"));
CollectionSphere->SetupAttachment(GetRootComponent());
CollectionSphere->SetSphereRadius(200.f);
将所有与角色重叠的组件存入数组,遍历数组,数组中的组件转换为电池基类
,成功并且电池没有被销毁也没有被拾取就调用电池被收集的处理方法,并将电池标记为已失去状态GetOverlappingActors
:TArray中的函数用于返回该组件的参与重叠者列表void ABatteryRetrieverCharacter::CollectPickups()
{
TArray<AActor*> CollectionActors;
//返回该组件的参与重叠者列表
CollectionSphere->GetOverlappingActors(CollectionActors);
float CollectPower = 0.f;//能力值
//遍历所有区域的电池,并存入数组
for (int32 i = 0; i < CollectionActors.Num(); i++)
{
ACollectActor* Collect = Cast<ACollectActor>(CollectionActors[i]);
//转换成功,电池没有被销毁,电池没有被拾取
if (Collect && !Collect->IsPendingKill() && Collect->IsActive())
{
Collect->WasCollected();//调用电池被收集的方法
Collect->SetActive(false);//电池被拾取
}
}
}
bIsActive = true;
/** PicktupC Input Action */
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = Input, meta = (AllowPrivateAccess = "true"))
class UInputAction* PicktupC;
//Pickup
EnhancedInputComponent->BindAction(PicktupC, ETriggerEvent::Triggered, this, &ABatteryRetrieverCharacter::CollectPickups);
UCLASS()
class BATTERYRETRIEVER_API ABatteryCollectActor : public ACollectActor
{
GENERATED_BODY()
public:
ABatteryCollectActor();
void WasCollected_Implementation()override;
//获取能量
float GetPower();
protected:
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Power")
float BatteryPower;
};
// Fill out your copyright notice in the Description page of Project Settings.
#include "BatteryCollectActor.h"
ABatteryCollectActor::ABatteryCollectActor()
{
//设置物理状态
GetMesh()->SetSimulatePhysics(true);
//电池能力值
BatteryPower = 200.f;
}
void ABatteryCollectActor::WasCollected_Implementation()
{
Super::WasCollected_Implementation();
//销毁电池
Destroy();
}
//返回能量值
float ABatteryCollectActor::GetPower()
{
return BatteryPower;
}
//初始能量值与角色能量值
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Power")
float InitalPower;
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Power")
float CharacterPower;
//------------------------------------------------------------------
InitalPower = 2000.f;
CharacterPower = InitalPower;
BlueprintPure
参数宏,第三个方法没有返回值,就不能加上BlueprintPure
宏,用BlueprintCallable
宏
UFUNCTION(BlueprintPure,Category="Power")
float GetInitialPower();
UFUNCTION(BlueprintPure, Category = "Power")
float GetCurrentPower();
UFUNCTION(BlueprintCallable, Category = "Power")
void UpdataPower(float PowerChange);
float ABatteryRetrieverCharacter::GetInitialPower()
{
return InitalPower;
}
float ABatteryRetrieverCharacter::GetCurrentPower()
{
return CharacterPower;
}
void ABatteryRetrieverCharacter::UpdataPower(float PowerChange)
{
CharacterPower += PowerChange;
}
void ABatteryRetrieverCharacter::CollectPickups()
{
TArray<AActor*> CollectionActors;
//返回该组件的参与重叠者列表
CollectionSphere->GetOverlappingActors(CollectionActors);
float CollectPower = 0.f;//能力值
//遍历所有区域的电池,并存入数组
for (int32 i = 0; i < CollectionActors.Num(); i++)
{
ACollectActor* Collect = Cast<ACollectActor>(CollectionActors[i]);
//转换成功,电池没有被销毁,电池没有被拾取
if (Collect && !Collect->IsPendingKill() && Collect->IsActive())
{
Collect->WasCollected();//调用电池被收集的方法
//检查CollectActor是否是BatteryCollect电池类
ABatteryCollectActor* Battery = Cast<ABatteryCollectActor>(Collect);
if (Battery)
{
CollectPower += Battery->GetPower();//如果是当前电池,就增加能量值
}
Collect->SetActive(false);//电池被拾取
}
}
if (CollectPower > 0.f)
{
UpdataPower(CollectPower);//更新能量值
}
}
// Copyright Epic Games, Inc. All Rights Reserved.
#pragma once
#include "CoreMinimal.h"
#include "GameFramework/GameModeBase.h"
#include "BatteryRetrieverGameMode.generated.h"
UCLASS(minimalapi)
class ABatteryRetrieverGameMode : public AGameModeBase
{
GENERATED_BODY()
public:
ABatteryRetrieverGameMode();
//衰减速率
UPROPERTY(EditAnywhere,BlueprintReadWrite,Category="Power")
float DecayRate;
protected:
//重写Tick
virtual void Tick(float DeltaTime) override;
};
// Copyright Epic Games, Inc. All Rights Reserved.
#include "BatteryRetrieverGameMode.h"
#include "BatteryRetrieverCharacter.h"
#include "UObject/ConstructorHelpers.h"
#include "Kismet/GameplayStatics.h"
ABatteryRetrieverGameMode::ABatteryRetrieverGameMode()
{
//开启Tick
PrimaryActorTick.bCanEverTick = true;
// set default pawn class to our Blueprinted character
static ConstructorHelpers::FClassFinder<APawn> PlayerPawnBPClass(TEXT("/Game/ThirdPerson/Blueprints/BP_ThirdPersonCharacter"));
if (PlayerPawnBPClass.Class != NULL)
{
DefaultPawnClass = PlayerPawnBPClass.Class;
}
DecayRate = 0.01f;
}
void ABatteryRetrieverGameMode::Tick(float DeltaTime)
{
Super::Tick(DeltaTime);
ABatteryRetrieverCharacter* MyCharacter = Cast<ABatteryRetrieverCharacter>(UGameplayStatics::GetPlayerPawn(this, 0));
if (MyCharacter)
{
if (MyCharacter->GetCurrentPower() > 0.f)
{
//每帧进行衰减能量
MyCharacter->UpdataPower(-(DeltaTime * DecayRate * MyCharacter->GetInitialPower()));
}
}
}
//速度因子
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Power")
float SpeedFactor;
//初始速度
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Power")
float BaseSpeed;
UFUNCTION(BlueprintImplementableEvent, BlueprintCallable, Category = "Power")
void PowerChangeEffect();
SpeedFactor = 0.75f;
BaseSpeed = 10.f;
void ABatteryRetrieverCharacter::UpdataPower(float PowerChange)
{
CharacterPower += PowerChange;
//根据Power改变玩家速度
GetCharacterMovement()->MaxWalkSpeed = BaseSpeed + SpeedFactor * CharacterPower;
}
在第三人称蓝图脚本中创建指定的材质实例
然后在Tick中去实现颜色的变化,注意UE5中的BlueprintImplementableEvent宏参数的函数,必须要调用了,UE4中使用的时候是不用调用的
Tint是第三人称模版材质中的颜色变换
//通关需要的能量值
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Power")
float PowerToWin;
//重写BeginPlay
virtual void BeginPlay() override;
void ABatteryRetrieverGameMode::BeginPlay()
{
Super::BeginPlay();
ABatteryRetrieverCharacter* MyCharacter = Cast<ABatteryRetrieverCharacter>(UGameplayStatics::GetPlayerPawn(this, 0));
//游戏通过条件
if (MyCharacter)
{
PowerToWin = MyCharacter->GetInitialPower() * 1.25f;
}
}
然后在项目名.Build.cs文件中添加模块
PublicDependencyModuleNames.AddRange(new string[] { “Slate”, “SlateCore” }); 表示将 Slate 和 SlateCore 模块添加为当前模块的公共依赖项。这意味着在编译当前模块时,编译器会确保先编译和链接 Slate 和 SlateCore 模块。
而 PublicDependencyModuleNames.AddRange(new string[] { “UMG” }); 则表示将 UMG 模块添加为当前模块的公共依赖项。由于 UMG 是基于 Slate 和 SlateCore 构建的,所以在启用 UMG 插件后,Slate 和 SlateCore 会自动成为项目的依赖项。
// Copyright Epic Games, Inc. All Rights Reserved.
using UnrealBuildTool;
public class BatteryRetriever : ModuleRules
{
public BatteryRetriever(ReadOnlyTargetRules Target) : base(Target)
{
PCHUsage = PCHUsageMode.UseExplicitOrSharedPCHs;
PublicDependencyModuleNames.AddRange(new string[] { "Core", "CoreUObject", "Engine", "InputCore", "HeadMountedDisplay", "EnhancedInput" });
PublicDependencyModuleNames.AddRange(new string[] { "Slate", "SlateCore" });
PublicDependencyModuleNames.AddRange(new string[] { "UMG" });
}
}
//HUD的Widget
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Power")
TSubclassOf<class UUserWidget> HUDWidgetClass;
//HUD实例
UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = "Power")
UUserWidget* CurrentWidget;
头文件#include "Blueprint/UserWidget.h"
void ABatteryRetrieverGameMode::BeginPlay()
{
Super::BeginPlay();
ABatteryRetrieverCharacter* MyCharacter = Cast<ABatteryRetrieverCharacter>(UGameplayStatics::GetPlayerPawn(this, 0));
//游戏通过条件
if (MyCharacter)
{
PowerToWin = MyCharacter->GetInitialPower() * 1.25f;
}
//创建UMG
if (HUDWidgetClass != nullptr)
{
CurrentWidget = CreateWidget<UUserWidget>(GetWorld(), HUDWidgetClass);
if (CurrentWidget)
{
CurrentWidget->AddToViewport();
}
}
}
UENUM(BlueprintType)
enum class EBatteryPlayState :uint8
{
EBPS_Playing UMETA(DisplayName="Playing"),
EBPS_GameOver UMETA(DisplayName = "GemaOver"),
EBPS_Won UMETA(DisplayName = "Won"),
EBPS_Unknown UMETA(DisplayName="Unknow")
};
//当前状态对象
EBatteryPlayState CurrentState;
//获取当前状态
UFUNCTION(BlueprintPure, Category = "State")
EBatteryPlayState GetCurrentState();
//设置当前状态
UFUNCTION(BlueprintCallable,Category="State")
void SetCurrentState(EBatteryPlayState StateName);
EBatteryPlayState ABatteryRetrieverGameMode::GetCurrentState()
{
return CurrentState;
}
void ABatteryRetrieverGameMode::SetCurrentState(EBatteryPlayState StateName)
{
CurrentState = StateName;
}
void ABatteryRetrieverGameMode::Tick(float DeltaTime)
{
Super::Tick(DeltaTime);
ABatteryRetrieverCharacter* MyCharacter = Cast<ABatteryRetrieverCharacter>(UGameplayStatics::GetPlayerPawn(this, 0));
if (MyCharacter)
{
if (MyCharacter->GetCurrentPower() > PowerToWin)
{
//游戏胜利
SetCurrentState(EBatteryPlayState::EBPS_Won);
}
else if (MyCharacter->GetCurrentPower() > 0.f)
{
//每帧进行衰减能量
MyCharacter->UpdataPower(-(DeltaTime * DecayRate * MyCharacter->GetInitialPower()));
}
else
{
//游戏结束
SetCurrentState(EBatteryPlayState::EBPS_GameOver);
}
}
}
//是否开启电池掉落
UFUNCTION(BlueprintCallable, Category = "Spawn Volume")
void SetSpawningActive(bool bState);
void ASpawnVolume::SetSpawningActive(bool bState)
{
if (bState)
{
SpawnDelay = FMath::FRandRange(MinDelayTimer, MaxDelayTimer);
GetWorld()->GetTimerManager().SetTimer(TimerHandle, this, &ASpawnVolume::SpawnPickup, SpawnDelay, false);
}
else
{
GetWorld()->GetTimerManager().ClearTimer(TimerHandle);
}
}
//记录关卡中的SpawnVolume
TArray<class SpawnVolume*> SpawnVolumeActors;
//处理玩家状态方法回调
void HandleNewState(EBatteryPlayState NewState);
void ABatteryRetrieverGameMode::BeginPlay()
{
Super::BeginPlay();
TArray<AActor*> FoundActors;
UGameplayStatics::GetAllActorsOfClass(GetWorld(), ASpawnVolume::StaticClass(), FoundActors);
for (auto Actor : FoundActors)
{
ASpawnVolume* SpawnVolumeActor = Cast<ASpawnVolume>(Actor);
if (SpawnVolumeActor)
{
SpawnVolumeActors.AddUnique(SpawnVolumeActor);
}
}
SetCurrentState(EBatteryPlayState::EBPS_Playing);
ABatteryRetrieverCharacter* MyCharacter = Cast<ABatteryRetrieverCharacter>(UGameplayStatics::GetPlayerPawn(this, 0));
//游戏通过条件
if (MyCharacter)
{
PowerToWin = MyCharacter->GetInitialPower() * 1.25f;
}
if (HUDWidgetClass != nullptr)
{
CurrentWidget = CreateWidget<UUserWidget>(GetWorld(), HUDWidgetClass);
if (CurrentWidget)
{
CurrentWidget->AddToViewport();
}
}
}
void ABatteryRetrieverGameMode::SetCurrentState(EBatteryPlayState StateName)
{
CurrentState = StateName;
HandleNewState(StateName);
}
void ABatteryRetrieverGameMode::HandleNewState(EBatteryPlayState NewState)
{
switch (NewState)
{
case EBatteryPlayState::EBPS_Playing:
for (ASpawnVolume* Volume : SpawnVolumeActors)
{
Volume->SetSpawningActive(true);
};
break;
case EBatteryPlayState::EBPS_GameOver:
for (ASpawnVolume* Volume : SpawnVolumeActors)
{
Volume->SetSpawningActive(false);
};
break;
case EBatteryPlayState::EBPS_Won:
break;
case EBatteryPlayState::EBPS_Unknown:
break;
default:
break;
}
}
#include "GameFramework/Character.h"
#include "GameFramework/PawnMovementComponent.h"
void ABatteryRetrieverGameMode::HandleNewState(EBatteryPlayState NewState)
{
switch (NewState)
{
case EBatteryPlayState::EBPS_Playing:
for (ASpawnVolume* Volume : SpawnVolumeActors)
{
Volume->SetSpawningActive(true);
};
break;
case EBatteryPlayState::EBPS_GameOver:
for (ASpawnVolume* Volume : SpawnVolumeActors)
{
Volume->SetSpawningActive(false);
APlayerController* PlayerControl = UGameplayStatics::GetPlayerController(this, 0);
if (PlayerControl)
{
//禁用部分输入
PlayerControl->SetCinematicMode(true, false, false, true, true);
}
//加入布娃娃系统
ACharacter* MyCharacter = UGameplayStatics::GetPlayerCharacter(this, 0);
if (MyCharacter)
{
MyCharacter->GetMesh()->SetSimulatePhysics(true);
MyCharacter->GetMovementComponent()->MovementState.bCanJump = false;
}
};
break;
case EBatteryPlayState::EBPS_Won:
break;
case EBatteryPlayState::EBPS_Unknown:
break;
default:
break;
}
}