No errors in VS, compile errors in UR

I’m creating my own C++ code inside the .h and .cpp inside my project. There are no errors in my project, but whenever I try and compile the project in the Unreal Editor, it comes up with a whole other bunch of errors. Does anyone know how to fix this?

255342-capture.png

255343-capture-2.png

255344-capture-3.png

Error panel in VS is not accurate ( doesn’t show some errors and some false errors show there )

The best is to compile from VS and check the “output” panel, you will be able to correct you code based on the errors there !

Sorry for not replying sooner, didn’t think someone would respond that fast.
I now see the same errors in VS, but what now?
I have been following tutorials on YT and they all work fine for them but whenever I write in the same code, it doesn’t work?

Let us see your code, we can help you debug it.

Probably an old tutorial, in 4.20, ue changed some includes rules an i guess your are missing one for audio comps !
Try yo add that at the begining of the .h file ( before the generated one )
#include “Runtime/Engine/Classes/Sound/SoundCue.h”

But as saidHarryHightDef, share the code so we can help you better

Enemy.h

#pragma once

UCLASS()
class HOLLOWWEAPONTEST_API AEnemy : public AActor
{
GENERATED_UCLASS_BODY()

UPROPERTY(visibleAnywhere, BlueprintReadOnly, Category = paper)
	class UPaperFlipbookComponent* EnemyComponent;

UPROPERTY(visibleAnywhere, BlueprintReadOnly, Category = paper)
	class UPaperFlipbook* EnemyAnimation;

UPROPERTY(visibleAnywhere, BlueprintReadOnly, Category = paper)
	class UPaperSpriteComponent* BallComponent;

public:
// Sets default values for this actor’s properties
AEnemy();

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

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

void MoveEnemy()
{

}

};

Enemy.cpp

#include “Enemy.h”
#include “PaperSpriteComponent.h”
#include “Paper2DClasses.h”
#include “Runtime/CoreUObject/Public/UObject/ConstructorHelpers.h”

// Sets default values
AEnemy::AEnemy(const class FObjectInitializer & PCIP)
:Super(PCIP)
{
// Set this actor to call Tick() every frame. You can turn this off to improve performance if you don’t need it.
PrimaryActorTick.bCanEverTick = true;

// Construct the animation
struct FConstructorStatics
{
	ConstructorHelpers::FObjectFinderOptional<UPaperFlipbook> EnemyAsset;
	FConstructorStatics()
		:EnemyAsset(TEXT("PaperFlipbook'/Game/Sprites/Characters/Enemies/WalkingMovement/WalkingMovement.WalkingMovement'"))
	{

	}
};

static FConstructorStatics ConstructorStatics;

EnemyAnimation = ConstructorStatics.EnemyAsset.Get();

EnemyComponent = PCIP.CreateDefaultSubobject<UPaperFlipbookComponent>(this, TEXT("EnemyComponent"));
EnemyComponent->SetFlipbook(EnemyAnimation);

// Attach Ball
BallComponent = PCIP.CreateDefaultSubobject<UPaperSpriteComponent>(this, TEXT("Ball"));
BallComponent->AttachTo(EnemyComponent, "head", EAttachLocation::SnapToTarget);

}

PawnMusic.h

#pragma once

#include “CoreMinimal.h”
#include “GameFramework/Pawn.h”
#include “PawnMusic.generated.h”

UCLASS()
class HOLLOWWEAPONTEST_API APawnMusic : public APawn
{
GENERATED_UCLASS_BODY()

UPROPERTY(BlueprintReadOnly, Category = "Audio")
	USoundCue* AudioCue;

UPROPERTY(BlueprintReadOnly, Category = "Audio")
	USoundCue* StartupCue;

UPROPERTY(BlueprintReadOnly, Category = "Audio")
	UAudioComponent* AudioComponent;

UPROPERTY(BlueprintReadOnly, Category = "Audio")
	USoundCue* Sound;

public:
// Sets default values for this pawn’s properties
APawnMusic();

protected:
void PostInitializeComponents();
// 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;

};

PawnMusic.cpp

#include “PawnMusic.h”
#include “Components/AudioComponent.h”
#include “Sound/SoundCue.h”
#include “Runtime/CoreUObject/Public/UObject/ConstructorHelpers.h”

// Sets default values
APawnMusic::APawnMusic()
{
// Set this pawn to call Tick() every frame.
PrimaryActorTick.bCanEverTick = true;
// Load the Sound Cue
static ConstructorHelpers::FObjectFinder SoundCue(TEXT(“SoundCue’/Game/Music/Music/HomeLevel_Song_Cue.HomeLevel_Song_Cue’”));

// Reference to the Cue asset
AudioCue = SoundCue.Object;
// Create an audio component
AudioComponent = CreateDefaultSubobject<UAudioComponent>(TEXT("AudioComp"));
// Follow the pawn around
AudioComponent->AttachParent = RootComponent;
// Set position in front of character
AudioComponent->SetRelativeLocation(FVector(100.0f, 0.0f, 0.0f));

}

void APawnMusic::PostInitializeComponents()
{
Super::PostInitializeComponents();

if (AudioCue->IsValidLowLevelFast()) {
	AudioComponent->SetSound(AudioCue);
}

}

// Called when the game starts or when spawned
void APawnMusic::BeginPlay()
{
Super::BeginPlay();
// Play music
AudioComponent->Play();
}

// Called every frame
void APawnMusic::Tick(float DeltaTime)
{
Super::Tick(DeltaTime);
float Rpm = Sound->lastRpm * Sound->reductionRatio;
AudioComponent->SetFloatParameter(FName(“pitch”), Rpm);
}

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

}

Apologies for the sloppiness