首页 > 技术文章 > UE4 4.25 体积检测 笔记

max404 2021-01-11 19:06 原文

创建组件
public:

InteractiveComponent = CreateDefaultSubobject<UInteractiveComponent>(FName("InteractiveComponent")); InteractiveComponent->InteractiveRadius = 150;

 

头文件 

#include "Kismet/KismetSystemLibrary.h"

源文件

//交互组件 生成检测函数
void
UInteractiveComponent::SpawnVolumeDetection() { //开始位置 结束位置 FVector StartLocation = this->GetOwner()->GetActorLocation(); FVector EndLocation = this->GetOwner()->GetActorLocation()+FVector(0,0,10);
  //忽略数组 TArray
<AActor*> IgnoreSelfArray; IgnoreSelfArray.Add(this->GetOwner());

  //体积检测返回 TArray
<FHitResult> HitResult;
  //球体检测 UKismetSystemLibrary::SphereTraceMulti(
this, StartLocation, EndLocation, InteractiveRadius, //半径 ETraceTypeQuery::TraceTypeQuery1, //不知道枚举 false, //复杂检测 IgnoreSelfArray, //忽略数组 EDrawDebugTrace::ForOneFrame, //一帧 HitResult, //返回结果数组 true, //忽略自身 FLinearColor::Red, //显示红 FLinearColor::Green, //显示蓝 5.0f //显示时间 ); }

 

 

 

推荐阅读