OnOverlapBegin_Implementation 和 OnOverlapBegin 有何不同?
how does OnOverlapBegin_Implementation means and OnOverlapBegin differs?
我很困惑
UFUNCTION(BlueprintNativeEvent,类别 = 碰撞)
void OnOverlapBegin(UPrimitiveComponent* Comp, AActor* otherActor, UPrimitiveComponent* otherComp, int32 otherBodyIndex, bool bFromSweep, const FHitResult& SweepResult);
和
虚空 OnOverlapBegin_Implementation(UPrimitiveComponent* Comp,
AActor* otherActor, UPrimitiveComponent* otherComp, int32 otherBodyIndex,
bool bFromSweep, const FHitResult& SweepResult)
有效。
本质上,这是一个关于BlueprintNativeEvent
函数说明符的问题。因此,您上面的顶级函数定义将在 class' 头文件中。
UFUNCTION(BlueprintNativeEvent, Category = Collision)
void OnOverlapBegin(UPrimitiveComponent* Comp, AActor* otherActor, UPrimitiveComponent* otherComp, int32 otherBodyIndex, bool bFromSweep, const FHitResult& SweepResult);
并且由于该函数说明符,该函数将被蓝图 class 覆盖,蓝图 class 是定义此函数的任何 C++ class 的子class。现在,这里的关键词是 meant。因此,蓝图覆盖此功能在技术上是可选的。但是,该函数仍可能被蓝图或 C++ 中的其他地方使用 class。因此,如果没有上述函数的重写版本,则会使用该函数的默认实现。您将在头文件中定义默认方法,并使用问题下半部分的签名在 C++ 文件中实现该方法。
virtual void OnOverlapBegin_Implementation(UPrimitiveComponent* Comp, AActor* otherActor, UPrimitiveComponent* otherComp, int32 otherBodyIndex, bool bFromSweep, const FHitResult& SweepResult);
尽管如此,我相信您甚至不需要在头文件中定义这个函数来实际实现该函数。所以你可以直接进入你的 C++ class 并像这样实现默认的 OnOverlapBegin
函数,
void RandomClass::OnOverlapBegin_Implementation(UPrimitiveComponent* Comp, AActor* otherActor, UPrimitiveComponent* otherComp, int32 otherBodyIndex, bool bFromSweep, const FHitResult& SweepResult)
{
// called if not overridden by blueprint or subclass
}
单击 here 了解有关 Unreal Engine 中接口的更多信息。
单击 here, here, and here 了解有关 BlueprintNativeEvent 函数说明符的更多信息。
我很困惑
UFUNCTION(BlueprintNativeEvent,类别 = 碰撞) void OnOverlapBegin(UPrimitiveComponent* Comp, AActor* otherActor, UPrimitiveComponent* otherComp, int32 otherBodyIndex, bool bFromSweep, const FHitResult& SweepResult);
和
虚空 OnOverlapBegin_Implementation(UPrimitiveComponent* Comp, AActor* otherActor, UPrimitiveComponent* otherComp, int32 otherBodyIndex, bool bFromSweep, const FHitResult& SweepResult)
有效。
本质上,这是一个关于BlueprintNativeEvent
函数说明符的问题。因此,您上面的顶级函数定义将在 class' 头文件中。
UFUNCTION(BlueprintNativeEvent, Category = Collision)
void OnOverlapBegin(UPrimitiveComponent* Comp, AActor* otherActor, UPrimitiveComponent* otherComp, int32 otherBodyIndex, bool bFromSweep, const FHitResult& SweepResult);
并且由于该函数说明符,该函数将被蓝图 class 覆盖,蓝图 class 是定义此函数的任何 C++ class 的子class。现在,这里的关键词是 meant。因此,蓝图覆盖此功能在技术上是可选的。但是,该函数仍可能被蓝图或 C++ 中的其他地方使用 class。因此,如果没有上述函数的重写版本,则会使用该函数的默认实现。您将在头文件中定义默认方法,并使用问题下半部分的签名在 C++ 文件中实现该方法。
virtual void OnOverlapBegin_Implementation(UPrimitiveComponent* Comp, AActor* otherActor, UPrimitiveComponent* otherComp, int32 otherBodyIndex, bool bFromSweep, const FHitResult& SweepResult);
尽管如此,我相信您甚至不需要在头文件中定义这个函数来实际实现该函数。所以你可以直接进入你的 C++ class 并像这样实现默认的 OnOverlapBegin
函数,
void RandomClass::OnOverlapBegin_Implementation(UPrimitiveComponent* Comp, AActor* otherActor, UPrimitiveComponent* otherComp, int32 otherBodyIndex, bool bFromSweep, const FHitResult& SweepResult)
{
// called if not overridden by blueprint or subclass
}
单击 here 了解有关 Unreal Engine 中接口的更多信息。
单击 here, here, and here 了解有关 BlueprintNativeEvent 函数说明符的更多信息。