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"

OnActorBeginOverlap fires in Blueprint but not in C++

I want to create a Projectile and therefore I was trying around with collision events. I created a very simple c++ class just with a SphereComponent and an overlap function

the .h

 /** sphere component */
         UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = "Projectile Components")
             USphereComponent* Sphere1;
         void OnOverlapBegin(class AActor* OtherActor);

the .cpp

      // Set this actor to call Tick() every frame.  You can turn this off to improve performance if you don't need it.
     PrimaryActorTick.bCanEverTick = true;
     Sphere1 = CreateDefaultSubobject<USphereComponent>(TEXT("Sphere1"));
     RootComponent = Sphere1;
     OnActorBeginOverlap.AddDynamic(this, &ATOEProjectile::OnOverlapBegin);
     void ATOEProjectile::OnOverlapBegin(class AActor* OtherActor)
         GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Red, TEXT("This is an on screen message!"));

I created a blueprint of it an simply move it by SetActorLocation(). When it collides with an other Actor ( a simple Box) nothing happens. But when I use the ActorBeginOverlap of the blueprinted class i get feedback.

I also tried this in 4.10.2 and got the same result. Am I doing somehting wrong here?

Product Version: UE 4.11 Preview
more ▼

asked Feb 08 '16 at 10:45 AM in C++ Programming

avatar image

33 6 7 11

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

1 answer: sort voted first

Try this! To call C++ parent function you must specify parent call if event overriden in Blueprint.

alt text

overlap.png (37.9 kB)
more ▼

answered Feb 08 '16 at 11:00 AM

avatar image

584 45 65 93

avatar image Denozone Feb 08 '16 at 11:14 AM

Not working and now it gets really odd because if I call the parent function and then print a message i can see the message

alt text

overlapevent.png (39.1 kB)
avatar image broly Feb 08 '16 at 11:39 AM

Try this code:

 virtual void NotifyActorBeginOverlap(AActor* OtherActor) override;

instead adding function to delegate

avatar image Denozone Feb 08 '16 at 12:12 PM

That worked! Thank you.

Where did you find that? I didnt't read about that function in any Documentation.


I now know why my Function didn't fire. In order to use a function as a delegate you have to use UFUNCTION() as prefix. That solved my problem.

Both ways worked.

(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