x

Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

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?

alt text

alt text

alt text

Product Version: UE 4.20
Tags:
capture.png (618 B)
capture-2.png (21.1 kB)
capture-3.png (18.3 kB)
more ▼

asked Oct 02 '18 at 08:22 AM in C++ Programming

avatar image

sablazek1234
1 1

(comments are locked)
10|2000 characters needed characters left

1 answer: sort voted first

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 !

more ▼

answered Oct 02 '18 at 09:01 AM

avatar image

Firefly74
1.4k 14 17 31

avatar image sablazek1234 Oct 04 '18 at 04:56 AM

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?

avatar image HarryHighDef Oct 04 '18 at 10:48 AM

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

avatar image Firefly74 Oct 04 '18 at 11:42 AM

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

avatar image sablazek1234 Oct 04 '18 at 12:44 PM

Enemy.h

pragma once

include "CoreMinimal.h"

include "PaperCharacter.h" #include "GameFramework/Actor.h" #include "Enemy.generated.h"

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);

}

avatar image sablazek1234 Oct 04 '18 at 12:47 PM

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;

};

avatar image sablazek1234 Oct 04 '18 at 12:47 PM

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);

}

avatar image sablazek1234 Oct 04 '18 at 12:48 PM

Apologies for the sloppiness

(comments are locked)
10|2000 characters needed characters left
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question