完善和打包
2023年12月14日 2024年1月11日
Packaging
API导航
APawn::TurnOff
暂停或游戏结束时调用, 停止游戏角色的音效, 动画等
1/** Freeze pawn - stop sounds, animations, physics, weapon firing */ 2virtual void TurnOff();
AActor::Reset
回合开始时调用
1/** Reset actor to initial state - used when restarting level without reloading. */ 2virtual void Reset();
完善游戏角色停止射击逻辑
- 游戏结束时, 所有游戏角色停止射击, 恢复照相机视场
- 游戏暂停时
- 开启新回合时
武器组件添加接口: 停止射击, 恢复照相机视场
public
ShootThemUp: Components/STUWeaponComponent.h
1void StopFireAndRecoverFOV();
ShootThemUp: Components/STUWeaponComponent.cpp
1void USTUWeaponComponent::StopFireAndRecoverFOV() 2{ 3 if (!CurrentWeapon) return; 4 CurrentWeapon->FireStop(); 5 CurrentWeapon->Zoom(false); 6}
覆写TurnOff
public
ShootThemUp: Player/STUPlayerCharacter.h
1virtual void TurnOff() override;
ShootThemUp: Player/STUPlayerCharacter.cpp
1void ASTUBaseCharacter::TurnOff() 2{ 3 WeaponComponent->StopFireAndRecoverFOV(); 4 Super::TurnOff(); 5}
覆写Reset
public
ShootThemUp: Player/STUPlayerCharacter.h
1virtual void Reset() override;
ShootThemUp: Player/STUPlayerCharacter.cpp
1void ASTUBaseCharacter::Reset() 2{ 3 WeaponComponent->StopFireAndRecoverFOV(); 4 Super::Reset(); 5}
游戏结束时, 会对Pawn调用TurnOff
ShootThemUp: STUGameModeBase.cpp
1// GameOver 2Pawn->TurnOff();
开启新回合时, 会对Pawn调用Reset
GameTimerUpdate > ResetPlayers > ResetOnePlayer
ShootThemUp: STUGameModeBase.cpp
1// ResetOnePlayer 2Controller->GetPawn()->Reset();
游戏暂停时
- 添加接口, 对所有游戏角色调用StopFireAndRecoverFOV
private
ShootThemUp: STUGameModeBase.h
1void AllStopFireAndRecoverFOV();
ShootThemUp: STUGameModeBase.cpp
1#include "Components/STUWeaponComponent.h" 2 3void ASTUGameModeBase::AllStopFireAndRecoverFOV() 4{ 5 for (auto Pawn : TActorRange<APawn>(GetWorld())) 6 { 7 if (!Pawn) continue; 8 9 const auto WeaponComponent = STUUtils::GetSTUPlayerComponent<USTUWeaponComponent>(Pawn); 10 if (!WeaponComponent) continue; 11 12 WeaponComponent->StopFireAndRecoverFOV(); 13 } 14}
- 游戏暂停时调用StopFireAndRecoverFOV
ShootThemUp: STUGameModeBase.cpp
1// SetPause 2 3if (PauseSet) 4{ 5 AllStopFireAndRecoverFOV(); 6 SetMatchState(ESTUMatchState::Pause); 7}
块作用域
用以减少代码行数
ShootThemUp: PLayer/STUPlayerController.cpp
1const auto GameMode = Cast<ASTUGameModeBase>(GetWorld()->GetAuthGameMode()); 2if (GameMode) 3{ 4 GameMode->OnMatchStateChanged.AddUObject(this, &ASTUPlayerController::OnMatchStateChanged); 5}
等价于
1if (const auto GameMode = Cast<ASTUGameModeBase>(GetWorld()->GetAuthGameMode())) 2{ 3 GameMode->OnMatchStateChanged.AddUObject(this, &ASTUPlayerController::OnMatchStateChanged); 4}
EQS: NPC巡逻
EQS_RandomRoam
当前使用圆锥点阵
如果PlayerStart的位置在角落, 存在NPC无法巡逻的可能
可以增大圆锥顶角
武器射程
原1500单位, 增至10000
-
步枪
-
发射器
打包
注意
-
当前检查组件是否有效, 依托于BeginPlay中的check宏. 而实际开发中, 这是必要不充分的. 仍应该在每次使用前进行检查
-
关卡选项
Death
在虚幻编译器中运行游戏可正确显示名称, 但在发行版本中显示为death
将
Death
修改为Monument
或Death match
则没有问题 -
打包时如若遇到
saved with empty engine version
告警, 须将对应资产重新保存