New C++ BP class not available when creating new BP

Hi all,

I’m trying to create a new blueprintable C++ class that inherits from ACharacter (via Tools > New C++ Class) in UE 5.1; however, the newly created class does not appear in the editor for selecting as a parent for a new BP.

The new class inherits from ACharacter so it should be Blueprintable and BlueprintType, which from what I’ve read is enough to make it eligible.

I’m not familiar with using UE with C++ and I’m banging my head against the wall so any help is much appreciated.

Thanks

Hi jorbascrumps,

Maybe take a look at Epics default FirstPerson or ThirdPerson Template code - just create a new project, specify the template and then make sure “C++” is set as the coding type.

They create a class based on ACharacter with a basic set of methods for handling movement etc - it’s nice code to learn from…

My project was created using the TP template and I’m looking to create a new class within it.

Ok, did you specify “Public” for the class type? I just tested here on my project (which is based on the FP template) and was able to see it when creating a new class…

Thanks for following up. Yes, I selected public when creating the class. Only the header file is in the public directory; I assume this is correct.

Perhaps it will help to provide the code.

MyCharacter.h

// Fill out your copyright notice in the Description page of Project Settings.

#pragma once

#include "CoreMinimal.h"
#include "GameFramework/Character.h"
#include "MyCharacter.generated.h"

UCLASS()
class PROJECTSURVIVAL_API AMyCharacter : public ACharacter
{
	GENERATED_BODY()

public:
	// Sets default values for this character's properties
	AMyCharacter();

protected:
	// Called when the game starts or when spawned
	virtual void BeginPlay() override;

public:	
	// Called every frame
	virtual void Tick(float DeltaTime) override;

	// Called to bind functionality to input
	virtual void SetupPlayerInputComponent(class UInputComponent* PlayerInputComponent) override;

};

MyCharacter.cpp

// Fill out your copyright notice in the Description page of Project Settings.


#include "MyCharacter.h"

// Sets default values
AMyCharacter::AMyCharacter()
{
 	// Set this character to call Tick() every frame.  You can turn this off to improve performance if you don't need it.
	PrimaryActorTick.bCanEverTick = true;

}

// Called when the game starts or when spawned
void AMyCharacter::BeginPlay()
{
	Super::BeginPlay();
	
}

// Called every frame
void AMyCharacter::Tick(float DeltaTime)
{
	Super::Tick(DeltaTime);

}

// Called to bind functionality to input
void AMyCharacter::SetupPlayerInputComponent(UInputComponent* PlayerInputComponent)
{
	Super::SetupPlayerInputComponent(PlayerInputComponent);

}

That’s exactly the same as mine - I even created a new one called “MyCharacter” so they would be identical.

Are you sure that it has compiled? Live coding should take care of that all - but maybe close your project down, open from VS and compile before running?

Thanks for confirming.

This may be a dumb question, but can you confirm I’m live coding correctly? :sweat_smile: I have my project open in VS, then hit Debug > Start Debugging, and that builds before opening UE.

yes - Live Live coding :smiley:

Maybe try building it in release mode and Executing rather than debug-go?

Having said that, I do it like you and I’m in debug mode and it worked…

Very strange! It’s at about this point that I reset my machine - it’s surprising how often that actually fixes things like this. Also, deleting your Intermediate folder and rebuilding can sometimes help too…

Hmm, I’ve now restarted my PC, deleted Intermediate, and went through the same debug process as above.

I’m unfamiliar with building in release mode…

That probably means it’s already in “Development Editor” (you can also set that to “DebugGame Editor” for all the debug symbols and tools)

image

So just on the slight off-chance - you could try “Start without Debugging”. If you use “Start Debugging” and you’re set to “Development Editor”, there’s a chance it tries to use the last built debug version without rebuilding - there’s a slim chance there’s a debug build from before you added the class…

image

Thanks for explaining all that. Didn’t seem to make a difference :slightly_frowning_face:

I made a new project with the TP template and was able to use the class correctly. I’m going to see if I can see what’s potentially different between the 2 projects…

Plan B - at least that’s working - yes it would be interesting to hear what caused it!

I hope I can figure it out as I’ve been working on this project for 6 months and the thought of porting it over just because of this is nauseating. I’ll let you know how it goes…

1 Like

Well, I think I found the cause!

In comparing configs between the 2 projects I noticed that the working project had the following in the .uproject file:

"Modules": [
	{
		"Name": "ProjectSurvival",
		"Type": "Runtime",
		"LoadingPhase": "Default",
		"AdditionalDependencies": [
			"Engine"
		]
	}
],

It sounded like something I’d need so I popped it into my project et voila! Suddenly my class shows up.

2 Likes

Yeah that would do it - good detective work! That’s useful to keep in mind if it ever happens again…

Maybe mark your comment there as the Answer in case anyone else has the same problem…

I thought I had read that generating the VS project files would “convert” the project over but I guess not…

Thanks so much for helping me with this, I really appreciate it!

1 Like