Hi,
I’m following the intro programming tutorials from unreal and I’m at the part where the battery class should be able to override the blueprint native event function created in the class it inherits from.
I currently have
UFUNCTION(BlueprintNativeEvent)
void OnPickedUp();
virtual void OnPickedUp_Implementation();
in the .h file for pickup and
void APickup::OnPickedUp_Implementation()
{
}
in the .cpp file.
For the class inheriting from pickup, I have
virtual void OnPickedUp_Implementation() override;
in the .h and
void AMyPickup::OnPickedUp_Implementation()
{
Super::OnPickedUp_Implementation();
Destroy();
}
in the .cpp file.
This is giving me the error
“Error 2 error LNK2001: unresolved external symbol “public: __cdecl AMyPickup::AMyPickup(void)” (??0AMyPickup@@QEAA@XZ)”
I’ve been poking around for a while and have been unsuccessful at finding a way to set this up that isn’t giving me errors. Thanks for your help!!
Hi MBrad,
Can you provide me the entire code files? According to the error, the issue may be something to do with the constructor of the AMyPickup class (Due to it showing AMyPickup::AMyPickup(void).) Another thing to try in the meantime is to comment out the overridden versions of the functions completely and see if the same error occurs when compiling.
Why do you have a virtual void OnPickedUp_Implementation() right underneath the void OnPickedUp() ?
Sure, here they are.link text
The compiler was complaining that it didn’t have it, even with the implementation function in the .cpp file.
It looks like the compiler didn’t like what you were doing with the constructor in the MyPickup class. You had two constructors declared and one defined. This is what was in the .h
AMyPickup();
AMyPickup(const FObjectInitializer FOI);
The default one can be removed and the other one that was made (with the ‘const FObjectInitializer FOI’ needs to be dereferenced, using a &. This would then look like:
AMyPickup(const FObjectInitializer& FOI);
The & will need to be added to the declaration in the .cpp as well. After doing this the compiler error was gone for me. Please let me know if this does not fix the issue for you.
Have a nice day,
No problem, be sure to let us know if you need any more assistance.