标签:ast extract UNC int fun NPU tor rom inpu
编写FPSGameMode
新建函数OnMissionComplete,并设置为蓝图可实现事件
UFUNCTION(BlueprintImplementableEvent,Category="GameMode") void OnMissionComplete(APawn* InstigatorPawn);
新建函数CompleteMission
void CompleteMission(APawn* InstigatorPawn);//确保其设在public下,能够从ExtractionZone调用
实现
void AFPSGameMode::CompleteMission(APawn* InstigatorPawn) { if (InstigatorPawn) { InstigatorPawn->DisableInput(nullptr);//禁用玩家控制器对它的控制 } OnMissionComplete(InstigatorPawn); }
实现HandleOverlap函数
void AFPSExtractionZone::HandleOverlap(UPrimitiveComponent * OverlappedComponent, AActor * OtherActor, UPrimitiveComponent * OtherComp, int32 OtherBodyIndex, bool bFromSweep, const FHitResult & SweepResult) { AFPSCharacter* MyPawn = Cast<AFPSCharacter>(OtherActor); if (MyPawn == nullptr) { return; } if (MyPawn->bIsCarryingObjective) { AFPSGameMode* GM = Cast<AFPSGameMode>(GetWorld()->GetAuthGameMode()); if (GM) { GM->CompleteMission(MyPawn); } } else { UGameplayStatics::PlaySound2D(this, ObjectiveMissingSound); } }
标签:ast extract UNC int fun NPU tor rom inpu
原文地址:https://www.cnblogs.com/suomeimei/p/10354852.html