UFUNCTION() //一定要加,否则无效 ,函数参数给定就行,原因要看底层代码,太过复杂
void OnSphereOverlap(UPrimitiveComponent* OverlappedComponent,
AActor* OtherActor, //触发时间的主体,通常是控制的人
UPrimitiveComponent* OterComp,
int32 OtherBodyIndex,
bool bFromSweep,
const FHitResult& SweepResult);
UFUNCTION() //离开触发的事件,参数给定就行
void OnSphereEndOverlap(UPrimitiveComponent* OverlappedComponent,
AActor* OtherActor,
UPrimitiveComponent* OtherComp,
int32 OtherBodyIndex);
//调用的设置,这里注意AddDynamic要自己写,不能用vs的智能输入
SphereArea->OnComponentBeginOverlap.AddDynamic(this, &AItem::OnSphereOverlap);
SphereArea->OnComponentEndOverlap.AddDynamic(this, &AItem::OnSphereEndOverlap);
UE4在C++中使用OnComponentBeginOverlap触发事件设置
最新推荐文章于 2024-04-15 10:57:44 发布