here is the problem , but it seems we can’t get the right help yet, I know and appreciate how most of the staff suffer to help and guide us.
again, I would confirm that when I add a class to a parent class , an error popup saying “Failed to add class, name already exist”
however when I go back to VS, I Found that it’s already added the class but fail to compile, even after removing the added files it cannot compile my project anymore.
I did that using UE4 version 4.7.3 which I installed using EPIC Launcher , Not GitHub version “source code” .
here is some screenshots:-
// Fill out your copyright notice in the Description page of Project Settings.
#pragma once
#include "GameFramework/Actor.h"
#include "PickUp.generated.h"
UCLASS()
class TUTORIALCODE_API APickUp : public AActor
{
GENERATED_UCLASS_BODY()
public:
// True when the pickup is able to be picked up, false if something deactivates the pickup //
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Pickup")
bool bIsActive;
// Simple collision primitive to use as the root component //
UPROPERTY(VisibleDefaultsOnly, BlueprintReadOnly, Category = "Pickup")
class USphereComponent* BaseCollisionComponent;
// StaticMeshComponent to represent the pickup in the level //
UPROPERTY(VisibleDefaultsonly, BlueprintReadOnly, Category = "Pickup")
class UStaticMeshComponent* PickUpMesh;
UFUNCTION(BlueprintNativeEvent)
void OnPickedUp();
public:
// Sets default values for this actor's properties
APickUp();
// Called when the game starts or when spawned
virtual void BeginPlay() override;
// Called every frame
virtual void Tick(float DeltaSeconds) override;
};
// Fill out your copyright notice in the Description page of Project Settings.
#include "TutorialCode.h"
#include "PickUp.h"
// Sets default values
APickUp::APickUp(const class FObjectInitializer& 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 = false;
//The PickUp is Valid when it is created
bIsActive = true;
// Create the root sphereComponent to handle the puckup's collision //
BaseCollisionComponent = PCIP.CreateDefaultSubobject<USphereComponent>(this, TEXT("BaseShpereComponent"));
// Set the SphereComponent as the root Component
RootComponent = BaseCollisionComponent;
//Create the static mesh component
PickUpMesh = PCIP.CreateDefaultSubobject<UStaticMeshComponent>(this, TEXT("PickUpMesh"));
//Turn physics on for the static mesh
PickUpMesh->SetSimulatePhysics(true);
// Attach the staticMeshComponent to the root component
PickUpMesh->AttachTo(RootComponent);
}
void APickUp::OnPickedUp_Implementation()
{
//there is no default behavior for a pickup when it is picked up
}
// Called when the game starts or when spawned
void APickUp::BeginPlay()
{
Super::BeginPlay();
}
// Called every frame
void APickUp::Tick(float DeltaTime)
{
Super::Tick(DeltaTime);
}
I was right, you have default constructor declaration but no implementation
“APickUp()”
Just make sure your declaration and implementation are the same
Hope it helps!
Believe me or not, I didn’t mean to be rude
To fix the project not compiling you should be able to delete the .h and .cpp file from your source folder for the project and then right click the .uproject and choose “Generate Project Files” which will correspondingly remove them from your project solution. Also, updating to the latest engine version should help. Let just know if you still have this problem if you update to 4.7.4.