标签: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);
标签:visible leo fps rom erb bsp lse cpp ted
原文地址:https://www.cnblogs.com/suomeimei/p/10353806.html