C++ Blueprint Callable Function not working

I am able to view the function fine in the blueprint I am using it in, however, the code body of the function in C++ itself is not running or being used at all. Example:

In the header of my character class:

UFUNCTION(BlueprintCallable, Category = "Mine") void BPCode(UStaticMeshComponent* staticmesh);

In the cpp of my character class:

void ATheCharacter::BPCode(UStaticMeshComponent* staticmesh)
{
	GEngine->AddOnScreenDebugMessage(-5, 10.f, FColor::Red, "BPCodeFIRED");
}

This is in a custom blank project, and I spawn a pawn with:

Atestfps_GameMode::Atestfps_GameMode(const class FPostConstructInitializeProperties& PCIP)
	: Super(PCIP)
{
	static ConstructorHelpers::FObjectFinder<UBlueprint> PlayerPawnObject(TEXT("Blueprint'/Game/Blueprints/MyStuff/Characters/BP_6dof.BP_6dof'"));
	if (PlayerPawnObject.Object != NULL)
	{
		DefaultPawnClass = (UClass*)PlayerPawnObject.Object->GeneratedClass;
	}
	
}

No matter what I do, I just can’t seem to get the actual function as I have it on the blueprint to fire off any of the actual c++ function body code.

Any ideas guys, or is this a bug? Thanks.

#Double Checking Spawning your Character Class

Can you override PostInitComponents of your character class

and double check by sending an onscreen message to yourself (that should appear as soon as game starts, in PIE or from commandline) ?

Just wanting to verify that your Character class is the one you are spawning.

Rama

None of my C++ functions that I assumed would be used in blueprint are being used. For example, I have

virtual void SetupPlayerInputComponent(class UInputComponent* InputComponent) OVERRIDE;

With MoveForward and MoveBack defined and written in C++, but in still only seems to use the blueprint coding for how things move and is completely ignoring all my C++. I’m really not sure why blueprint is responding this way (as I’m new to UE4.)

““LOADED OK” is not appearing.”

this means that your custom pawn class is not being used!

Are you sure your blueprint asset path was copied correctly?

static ConstructorHelpers::FObjectFinder<UBlueprint> PlayerPawnObject(TEXT("Blueprint'/Game/Blueprints/MyStuff/Characters/BP_6dof.BP_6dof'"));

You can verify the issue like this

static ConstructorHelpers::FObjectFinder<UBlueprint> PlayerPawnObject(TEXT("Blueprint'/Game/Blueprints/MyStuff/Characters/BP_6dof.BP_6dof'"));
    if (PlayerPawnObject.Object != NULL)
    {
       DefaultPawnClass = (UClass*)PlayerPawnObject.Object->GeneratedClass;
    }
else
{
  GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Blue, TEXT("TheCharacter BP WAS NOT LOADED"));
}

if you dont see the onscreen try using UE_LOG

I tried:

class ATheCharacter : public ACharacter
{
	GENERATED_UCLASS_BODY()

	virtual void BeginPlay() OVERRIDE;

.....
....
.....
....
}

void ATheCharacter::BeginPlay()
{
	Super::BeginPlay();

	if (GEngine)
	{
		GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Blue, TEXT("TheCharacter: LOADED OK"));
	}
}

The top is in the header clearly, and the second is in the cpp overriding it . “LOADED OK” is not appearing.

I don’t think I was spawning the right cpp file as what I wanted for my character. Now I have to go back and rebuild it with a camera and various things in C++ (Unless I can figure out how to load up a blueprint into how I fixed it, which was: DefaultPawnClass = ATheCharacter::StaticClass():wink:

I wanted to load up the blueprint of the pawn from the C++, so I could have access and manipulate the blueprint in the editor and make use of some of it’s features, while still having full access to c++ (which I’m a longtime codemonkey) as I prefer to write rather than visualize with boxes.

At this point I just now need to figure out how to tie my custom h/cpp ‘ATheCharacter’ in with a blueprint, and I’m all set.