美文网首页
10 - Collecting Pickups

10 - Collecting Pickups

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

为BayyteryCollectorCharacter 添加电池拾取功能
声明函数 CollectPickups()

Paste_Image.png

为该函数绑定输入
进入UE4 ProjectSetting/Input中 添加动作Collect 快捷键C

进入ABatteryCollectorCharacter::SetupPlayerInputComponent 添加

Paste_Image.png

编写CollectPickup函数
void ABatteryCollectorCharacter::CollectPickups()
{
TArray<AActor> CollectedActors;
CollectionSphere->GetOverlappingActors(CollectedActors); // 收集所有与SphereComponent碰撞的actor
for (int32 iCollected = 0; iCollected < CollectedActors.Num(); ++iCollected)
{
APickUp
const TestPickup = Cast<APickUp>(CollectedActors[iCollected]);
if (TestPickup && !TestPickup->IsPendingKill() && TestPickup->IsActive()) //判断如果该物体是PickUp并且没有被杀死 并且处于激活状态
{
TestPickup->WasCollected();
TestPickup->SetActive(false);
}

}

}

运行程序 打开 debug窗口 当人物走到电池旁边 按下C 会出现log

Paste_Image.png

相关文章

  • 10 - Collecting Pickups

    为BayyteryCollectorCharacter 添加电池拾取功能声明函数 CollectPickups()...

  • Collecting Stamp

    最近尝试第一次英语演讲,下面是我当时的演讲稿(请了高手修改指点),配上中文,感觉中文能更好的表达自己。 Have ...

  • Collecting Nectar

    Collecting Nectar By Cheng Lie If a new sign must be give...

  • 保罗的祷告pickups

    文章列举了祷告的各样益处。作者用父母的祷告距离,说明了他们父母在他们属灵成长中的重要作用。父母认真的祷告,不是给孩...

  • angular2-chapter06

    Collecting Data with Forms and Validation Check code at: ...

  • Rent calculator-Leasing Expert

    This is a platform for collecting rental information, you...

  • chapter 7

    Linking Linking is the process of collecting and combinin...

  • #say something#

    the picture above shows the process of collecting water a...

  • Learning Stata

    Collecting stata commands that are very useful but not us...

  • 2019-03-08

    NStextview note: we use textview for collecting the logs ...

网友评论

      本文标题:10 - Collecting Pickups

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