首页 > 编程语言 > 详细

UE4在C++中使用OnComponentBeginOverlap之类的时间

时间:2016-02-12 20:55:29      阅读:1898      评论:0      收藏:0      [点我收藏+]

首先说明一下,官方文档是错的,在4.10版本下,绑定函数在角色类的构造函数中不起作用。2016.2.12

这里角色类为例

首先在头文件中添加:

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

OnOverlapBegin为自己定义的碰撞函数

 

然后在Cpp文件中的SetupPlayerInputComponent函数中添加绑定函数:

StartCollectionSphere->OnComponentBeginOverlap.AddDynamic(this, &AThirdPersonCharacter::OnOverlapBegin);

StartCollectionSphere自己定义的USphereComponent。AThirdPersonCharacter为角色类。

 

之后添加碰撞函数的定义

void AThirdPersonCharacter::OnOverlapBegin(class AActor* OtherActor, class UPrimitiveComponent* OtherComp, int32 OtherBodyIndex, bool bFromSweep, const FHitResult& SweepResult)
{
  GEngine->AddOnScreenDebugMessage(0, 1.0f, FColor::Red, TEXT("!!!!!!"));
}

 

UE4在C++中使用OnComponentBeginOverlap之类的时间

原文:http://www.cnblogs.com/blueroses/p/5187236.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!