首页 > 其他 > 详细

Create Extraction Zone

时间:2019-02-06 17:06:48      阅读:80      评论:0      收藏:0      [点我收藏+]

标签:reat   对象   选择   文件中   ive   nco   hidden   ntb   rbo   

添加C++类,名称为FPSExtractionZone

添加盒体组件,进行公开处理,并设置为随处可见

    UPROPERTY(VisibleAnywhere,Category="Components")
    UBoxComponent* OverlapComp;

在Cpp文件中添加头文件

#include "Components/BoxComponent.h"

对刚才定义的组件进行实例化

    OverlapComp = CreateDefaultSubobject<UBoxComponent>(TEXT("OverlapComp"));//创建默认子对象并为它命名
    OverlapComp->SetCollisionEnabled(ECollisionEnabled::QueryOnly);//设置碰撞为启动,类型为只发出查询
    OverlapComp->SetCollisionResponseToAllChannels(ECR_Ignore);//设置碰撞为响应所有通道,设置为忽略
    OverlapComp->SetCollisionResponseToChannel(ECC_Pawn, ECR_Overlap);//设置碰撞为响应指定通道,仅选择人形体进行设置
    OverlapComp->SetBoxExtent(FVector(200.0f));//设置响应范围,XYZ轴均为200个单位长度

设置根组件

    RootComponent = OverlapComp;

绑定到OnComponentBeginOverlap

verlapComp->OnComponentBeginOverlap.AddDynamic(this, &AFPSExtractionZone::HandleOverlap);

按Alt+G进入内部

技术分享图片

再按Alt+G

技术分享图片

复制后面的参数

技术分享图片

声明函数,并标记为UFUNCTION

    UFUNCTION()
    void HandleOverlap(UPrimitiveComponent* OverlappedComponent, AActor* OtherActor, UPrimitiveComponent*  OtherComp, int32 OtherBodyIndex, bool bFromSweep, const FHitResult& SweepResult);

输出日志:

UE_LOG(LogTemp, Log, TEXT("Overlap"));

将OverlapComp设置为游戏中的隐藏项

    OverlapComp->SetHiddenInGame(false);

 

Create Extraction Zone

标签:reat   对象   选择   文件中   ive   nco   hidden   ntb   rbo   

原文:https://www.cnblogs.com/suomeimei/p/10353806.html

(0)
(0)
   
举报
评论 一句话评论(0
0条  
登录后才能评论!
© 2014 designnerd.net 版权所有 鲁ICP备09046678号-4
打开技术之扣,分享程序人生!
             

鲁公网安备 37021202000002号