Problems with custom classes from tutorial video

Alright so to get acquainted with the workings of UE4 coding, I watched some tutorial videos from Epic. First, I followed this video to build the source. Then, I began to follow the steps of this video to add some code to a project. So, in line with the steps there, after building / running the solution, I created a new project (“Pizza”). Then I added the same code that he added:

Powerup.h -

#pragma once

#include "GameFramework/Actor.h"
#include "Powerup.generated.h"

/**
 * 
 */
UCLASS()
class APowerup : public AActor
{
	GENERATED_UCLASS_BODY()

	UPROPERTY(VisibleDefaultsOnly, Category = Powerup)
	TSubobjectPtr<USphereComponent> TouchSphere;
	
	UPROPERTY(EditDefaultsOnly, Category = Powerup)
	float RotationRate;

	virtual void Tick(float DeltaTime) OVERRIDE;
};

Powerup.cpp -

#include "Pizzav2.h"
#include "Powerup.h"


APowerup::APowerup(const class FPostConstructInitializeProperties& PCIP)
	: Super(PCIP)
{
	PrimaryActorTick.bCanEverTick = true;

	TouchSphere = PCIP.CreateDefaultSubobject<USphereComponent>(this, TEXT("TouchSphereComponent"));
	TouchSphere->SetSphereRadius(20.f, false);
	RootComponent = TouchSphere;

	RotationRate = 180.f;
}

void APowerup::Tick(float DeltaTime)
{
	Super::Tick(DeltaTime);

	fRotator MyRot = GetActorRotation();
	MyRot.Roll += RotationRate * DeltaTime;
	SetActorRotation(MyRot);
}

Then, I ran the new code, using the “debug editor” mode. It then opens the screen where I can choose a project; I choose “Pizza”. But in “Pizza”, when I go to add a new blueprint and try to select “Powerup” as my parent class, it doesn’t show up! Here’s an image to show you what I mean.

Any idea what’s going wrong? I hope I didn’t miss something stupidly obvious… I’d be happy to provide any additional information about what I did, if that helps.

UCLASS(Blueprintable, BlueprintType)
class AAI_Monster : public AAI_Character

UClass has to be blueprintable.

I added that and it did not solve the problem.

#pragma once

#include "GameFramework/Actor.h"
#include "Powerup.generated.h"

/**
 * 
 */
UCLASS(Blueprintable, BlueprintType)
class APowerup : public AActor
{
	GENERATED_UCLASS_BODY()

	UPROPERTY(VisibleDefaultsOnly, Category = Powerup)
	TSubobojectPtr<USphereComponent> TouchSphere;
	
	UPROPERTY(EditDefaultsOnly, Category = Powerup)
	float RotationRate;

	virtual void Tick(float DeltaTime) OVERRIDE;
};

Were there any kind of errors in the compiler at all?

What happens if you try to do Add Code to project and check the show all classes to see if your powerup is in that list? I can not get into the editor currently as I’m adding new classes my self.

When I try to add code, I don’t see powerup on the list :confused:

First of all, child class of AActor does not need Blueprintable as it’s inherent that specifier from AActor, so thats definitely was not a problem

Code looks ok to me, so best guess (guessing that too) is that compiler misses your class for some reason. Rebuild your project (so everything is compiled from zero) and paste compiler output.

Regarding errors - I don’t see anything in particular, besides “Cannot find or open PDB file” (which, I’m quite sure, is not important). Here’s a pastebin to my entire build output, though, just in case.

Alright, I rebuilt the whole solution, here’s the output:

Pathing issue? Maybe?

I have a question did you open the project solution only? It look like you are building the unreal engine as well.

Can you open only the solution for your project? This can befound in:

Documents\Unreal Projects\Pizzav2\Pizzav2.sln

I think you are missing the errors because you are building the engine as well. Opening the solution file will show only issues for your project.

-------- End Detailed Actions Stats -----------------------------------------------------------
24>ERROR : UBT error : Failed to produce item: A:\Documents\Unreal Projects\Pizzav2\Binaries\Win64\UE4Editor-Pizzav2-Win64-Debug.dll
24> Cumulative action seconds (8 processors): 0.00 building projects, 3941.74 compiling, 0.00 creating app bundles, 0.00 generating debug info, 581.18 linking, 0.00 other
24> UBT execution time: 1232.40 seconds
24>C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V120\Microsoft.MakeFile.Targets(43,5): error MSB3073: The command “A:\Documents\GitHub\UnrealEngine\Engine\Build\BatchFiles\Rebuild.bat Pizzav2Editor Win64 Debug “A:\Documents\Unreal Projects\Pizzav2\Pizzav2.uproject”” exited with code 2.

First Error:

fRotator to → FRotator

That might fix the rest case sensitive types. Also with just the solution open if you open the Pizzav2Character.cpp it should now show red marks for these errors.

:slight_smile:

2> Pizzav2Character.cpp
2>A:\Documents\Unreal Projects\Pizzav2\Source\Pizzav2\Powerup.cpp(21): error C2065: ‘fRotator’ : undeclared identifier
2>A:\Documents\Unreal Projects\Pizzav2\Source\Pizzav2\Powerup.cpp(21): error C2146: syntax error : missing ‘;’ before identifier ‘MyRot’
2>A:\Documents\Unreal Projects\Pizzav2\Source\Pizzav2\Powerup.cpp(21): error C2065: ‘MyRot’ : undeclared identifier
2>A:\Documents\Unreal Projects\Pizzav2\Source\Pizzav2\Powerup.cpp(22): error C2065: ‘MyRot’ : undeclared identifier
2>A:\Documents\Unreal Projects\Pizzav2\Source\Pizzav2\Powerup.cpp(22): error C2228: left of ‘.Roll’ must have class/struct/union
2> type is ‘unknown-type’
2>A:\Documents\Unreal Projects\Pizzav2\Source\Pizzav2\Powerup.cpp(23): error C2065: ‘MyRot’ : undeclared identifier

also note that if the but errors out it will still let you run the last properly built exe which is why you was able to run but saw none of your changes.

Ah, you must be right. I was rebuilding the whole thing (Solution ‘Pizzav2’), which included the engine as well. However, I did open the Pizzav2.sln file, as you can see from the screenshot. Here’s the output to rebuilding just the actual game project (the one inside the “Games” folder):

Great, thanks, the problem is now fixed. Strange that I didn’t see (or notice?) the red line beforehand.