x

Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

OnComponentBeginOverlap doesn't work after Update to 4.3

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: https://answers.unrealengine.com/questions/71040/43-add-dynamic-on-component-overlap-error.html

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();

Product Version: Not Selected
Tags:
more ▼

asked Jul 21 '14 at 06:22 AM in C++ Programming

avatar image

edisonwang
6 2 3 6

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

1 answer: sort voted first
more ▼

answered Jul 24 '14 at 03:21 PM

avatar image

ledgarl
18 1 2 3

(comments are locked)
10|2000 characters needed characters left
Viewable by all users
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question