Hello World, C++ noob here. I have a project made in blueprint, and I’m trying to convert everything in C++.
I’m having only 1 problem. I have an NPC Character (NPCInteractive), an AI, and I want to cast it into my Player Character, because I have fonctions into my NPC that I want to call in my Player. Here is the CPP file:
#include "WithLoveFromTahitiCharacter.h"
#include "NPCInteractive.h"
// launch dialogue input
PlayerInputComponent->BindAction("LaunchDialogue", IE_Released, this, &AWithLoveFromTahitiCharacter::LaunchDialogue);
void AWithLoveFromTahitiCharacter::LaunchDialogue()
{
ANPCInteractive* NPCInteractive = Cast<ANPCInteractive>(GetOwner());
if (NPCInteractive != nullptr)
{
UE_LOG(LogTemp, Warning, TEXT("OVERLAP"))
}
else
{
UE_LOG(LogTemp, Warning, TEXT("NULL"))
}
}
When I press the LaunchDialogue button, it return always NULL
Here is the .h file:
#include "WithLoveFromTahitiCharacter.generated.h"
class ANPCInteractive;
UCLASS(config=Game)
class AWithLoveFromTahitiCharacter : public ACharacter
{
...
}
Thank you for your help guys and sorry for my english (I’m stuck for 1 week now lol).