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

Create Extraction Zone

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

标签:visible   leo   fps   rom   erb   bsp   lse   cpp   ted   

添加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

标签:visible   leo   fps   rom   erb   bsp   lse   cpp   ted   

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

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