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"

Office Holiday

Epic Games' offices will be on holiday from June 22nd to July 7th. During this period support will be limited. Our offices will reopen on Monday, July 8th. 

OnComponentBeginOverlap doesn't work in base class

Hey Guys, I have a problem with the OnComponentBeginOverlap() function.

I think I will show u in code what doesn't work:

// THIS CODE DOESN'T WORK

 //baseClass.h
 
 
 UCLASS(abstract)
 class (ProjectName)_API baseClass : public AActor
 {
 GENERATED_BODY()
 
 public: 
 UFUNCTION()
 void OnComponentBeginOverlap(class UPrimitiveComponent* OverlappedComp, class AActor* OtherActor, class UPrimitiveComponent* OtherComp, int32 OtherBodyIndex, 
 bool bFromSweep, const FHitResult& SweepResult); 
 };
 
 //baseClass.cpp
 void baseClass::baseClass::OnComponentBeginOverlap(class UPrimitiveComponent* OverlappedComp, class AActor* OtherActor, class UPrimitiveComponent* OtherComp, int32 OtherBodyIndex, 
 bool bFromSweep, const FHitResult& SweepResult) 
 {};
 
 //BUT THIS CODE WORKS
 //baseClass.h
 
 
 UCLASS(abstract)
 class (ProjectName)_API baseClass : public AActor
 {
 GENERATED_BODY()
 };
 
 //derivedClass.h
 UCLASS(abstract)
 class (ProjectName)_API derivedClass : public baseClass
 {
 public: 
 UFUNCTION()
 void OnComponentBeginOverlap(class UPrimitiveComponent* OverlappedComp, class AActor* OtherActor, class UPrimitiveComponent* OtherComp, int32 OtherBodyIndex, 
 bool bFromSweep, const FHitResult& SweepResult); 
 };
 
 //derivedClass.cpp 
 void derivedClass::derivedClass::void OnComponentBeginOverlap(class UPrimitiveComponent* OverlappedComp, class AActor* OtherActor, class UPrimitiveComponent* OtherComp, int32 OtherBodyIndex, 
 bool bFromSweep, const FHitResult& SweepResult)
 {}

Now u see, there is the exakt same code in the derived class as in the base class. But the code in the derived class works. So I don't wanna have just one abstraction level for collision detection, maybe some work around here?

The error is unresolved external errors from all class inherit from baseclass. But the derivedClass also has some other derived classes from it. So it can't be the issue here.

Product Version: UE 4.20
Tags:
more ▼

asked Sep 19 '18 at 08:21 PM in C++ Programming

avatar image

Josai
8 1 3

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

1 answer: sort voted first

why do you have "baseClass::baseClass::" only one should be necessary

usually " unresolved external errors " mean the function declared in .h is not found in .cpp ( to make it simple, it can be for some other reasons ) so double check your signature is the same and class name is good

could you share original code ? because error is probably a simple typo or something we can't see on pseudo code :/

more ▼

answered Sep 20 '18 at 11:57 AM

avatar image

Firefly74
1.5k 14 18 32

(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