码迷,mamicode.com
首页 > 其他好文 > 详细

Setup Mission End

时间:2019-02-07 16:27:46      阅读:173      评论:0      收藏:0      [点我收藏+]

标签: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);
    }
}

 

Setup Mission End

标签:ast   extract   UNC   int   fun   NPU   tor   rom   inpu   

原文地址:https://www.cnblogs.com/suomeimei/p/10354852.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!