其他分享
首页 > 其他分享> > Setup Mission End

Setup Mission End

作者:互联网

编写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);
    }
}

 

标签:CompleteMission,End,APawn,void,Mission,OnMissionComplete,InstigatorPawn,MyPawn,S
来源: https://www.cnblogs.com/suomeimei/p/10354852.html