I wrote some C++ code in 4.2 for overlap experiment, but after update to 4.3 I got some build errors.
I followed this like changed some code: 4.3 Add Dynamic On Component Overlap error - World Creation - Epic Developer Community Forums
Now, it can pass the build but the overlap event still doesn’t work in the game.
Changes I did are like this:
diff --git a/Source/Rift2/BluePortalCode.cpp b/Source/Rift2/BluePortalCode.cpp
index 8d8d319..c889515 100644
--- a/Source/Rift2/BluePortalCode.cpp
+++ b/Source/Rift2/BluePortalCode.cpp
@@ -12,12 +12,12 @@ ABluePortalCode::ABluePortalCode(const class FPostConstructInitializeProperties&
touchBox = PCIP.CreateDefaultSubobject<UBoxComponent>(this, TEXT("touchBox"));
RootComponent = touchBox;
- touchBox->OnComponentBeginOverlap.AddDynamic(this, &ABluePortalCode::OnOverlap);
+ touchBox->OnComponentBeginOverlap.AddDynamic(this, &ABluePortalCode::OnBeginOverlap);
}
-void ABluePortalCode::OnOverlap(AActor* OtherActor, UPrimitiveComponent* OtherComp, int32 OtherBodyIndex)
+void ABluePortalCode::OnBeginOverlap(class AActor* OtherActor, class UPrimitiveComponent* OtherComp, int32 OtherBodyIndex, bool bFromSweep, const FHitResult & SweepResult)
{
if (GEngine)
GEngine->AddOnScreenDebugMessage(-1, 5, FColor::Red, "Overlapped in C++");
diff --git a/Source/Rift2/BluePortalCode.h b/Source/Rift2/BluePortalCode.h
index 7efb20c..27bb910 100644
--- a/Source/Rift2/BluePortalCode.h
+++ b/Source/Rift2/BluePortalCode.h
@@ -9,7 +9,7 @@
*
*/
UCLASS()
-class ABluePortalCode : public AActor
+class RIFT2_API ABluePortalCode : public AActor
{
GENERATED_UCLASS_BODY()
@@ -21,7 +21,7 @@ class ABluePortalCode : public AActor
/** called when something overlaps the sphere component */
UFUNCTION()
- void OnOverlap(class AActor* OtherActor, class UPrimitiveComponent* OtherComp, int32 OtherBodyIndex);
+ void OnBeginOverlap(class AActor* OtherActor, class UPrimitiveComponent* OtherComp, int32 OtherBodyIndex, bool bFromSweep, const FHitResult & SweepResult);
UFUNCTION()
void ClearIsTeleportingFlag();
diff --git a/Source/Rift2/RedPortalCode.cpp b/Source/Rift2/RedPortalCode.cpp
index 5d4e55a..b225168 100644
--- a/Source/Rift2/RedPortalCode.cpp
+++ b/Source/Rift2/RedPortalCode.cpp
@@ -11,12 +11,12 @@ ARedPortalCode::ARedPortalCode(const class FPostConstructInitializeProperties& P
isTeleporting = false;
touchBox = PCIP.CreateDefaultSubobject<UBoxComponent>(this, TEXT("touchBox"));
RootComponent = touchBox;
- touchBox->OnComponentBeginOverlap.AddDynamic(this, &ARedPortalCode::OnOverlap);
+ touchBox->OnComponentBeginOverlap.AddDynamic(this, &ARedPortalCode::OnBeginOverlap);
}
-void ARedPortalCode::OnOverlap(AActor* OtherActor, UPrimitiveComponent* OtherComp, int32 OtherBodyIndex)
+void ARedPortalCode::OnBeginOverlap(class AActor* OtherActor, class UPrimitiveComponent* OtherComp, int32 OtherBodyIndex, bool bFromSweep, const FHitResult & SweepResult)
{
if (GEngine)
GEngine->AddOnScreenDebugMessage(-1, 5, FColor::Red, "Overlapped in C++");
diff --git a/Source/Rift2/RedPortalCode.h b/Source/Rift2/RedPortalCode.h
index 9dbdc98..5456dbf 100644
--- a/Source/Rift2/RedPortalCode.h
+++ b/Source/Rift2/RedPortalCode.h
@@ -9,7 +9,7 @@
*
*/
UCLASS()
-class ARedPortalCode : public AActor
+class RIFT2_API ARedPortalCode : public AActor
{
GENERATED_UCLASS_BODY()
@@ -21,7 +21,7 @@ class ARedPortalCode : public AActor
/** called when something overlaps the sphere component */
UFUNCTION()
- void OnOverlap(class AActor* OtherActor, class UPrimitiveComponent* OtherComp, int32 OtherBodyIndex);
+ void OnBeginOverlap(class AActor* OtherActor, class UPrimitiveComponent* OtherComp, int32 OtherBodyIndex, bool bFromSweep, const FHitResult & SweepResult);
UFUNCTION()
void ClearIsTeleportingFlag();