美文网首页
12 - Powering Up the Character

12 - Powering Up the Character

作者: 镜月s | 来源:发表于2017-09-18 16:02 被阅读12次

    编辑ABatteryCollectorCharacter::CollectPickups

    void ABatteryCollectorCharacter::CollectPickups()
    {
    TArray<AActor> CollectedActors;
    CollectionSphere->GetOverlappingActors(CollectedActors);
    float CollectedPower = 0;
    for (int32 iCollected = 0; iCollected < CollectedActors.Num(); ++iCollected)
    {
    APickUp
    const TestPickup = Cast<APickUp>(CollectedActors[iCollected]);
    if (TestPickup && !TestPickup->IsPendingKill() && TestPickup->IsActive())
    {
    TestPickup->WasCollected();
    ABatteryPickUp* const TestBattery = Cast<ABatteryPickUp>(TestPickup); //用于判断PickUp是不是BatteryPickUp
    if (TestBattery)
    {
    CollectedPower += TestBattery->GetPower(); // 更新Power
    }
    TestPickup->SetActive(false);
    }

    }
    if (CollectedPower > 0)
    {
        UpdatePower(CollectedPower); // 更新Power
    }
    

    }

    运行 观察Character 的CharacterPower属性 当人物走到电池身边时 按C 数值增加

    Paste_Image.png

    相关文章

      网友评论

          本文标题:12 - Powering Up the Character

          本文链接:https://www.haomeiwen.com/subject/nmsbsxtx.html