Error 2084 Function already has a body

Hello everyone!

I am having problems with a function in my projectile class. It says that my function already has a body, which I don’t really understand. Every class starts with this function right?:

AFPSProjectile::AFPSProjectile(const class FObjectInitializer& PCIP)
	: Super(PCIP)
{

}

I acctually do have a header file:

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

#pragma once

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

/**
 * 
 */
UCLASS()
class FPSPROJECT_API AFPSProjectile : public AActor
{
	GENERATED_BODY()
public:
	UPROPERTY(VisibleDefaultsOnly, Category = Projectile)
	/**TSubobjectPtr<USphereComponent> CollisionComp;   4.5 method (Now deprecated)  */
	USphereComponent* CollisionComp;
	
	/** Projectile movement component */
	UPROPERTY(VisibleAnywhere, Category = Movement)
	/**TSubobjectPtr<class UProjectileMovementComponent> ProjectileMovement;   4.5 method(Now deprecated)  */
	UProjectileMovementComponent* ProjectileMovement;

	void InitVelocity(const FVector& ShootDirection);
};

I hope you can help me solve this problem, and explain me what I did wrong!

Thanks in advance,
NeusAap

P.S I am using engine version 4.6 preview

You need to reference the default constructor in the header file.

Put:


AFPSProjectile(const class FObjectInitializer& PCIP);

into FPSProjectile.h.

PS: btw I’d advise you to now rename PCIP to ObjectInitializer from now on as it seems to have become the name they use. It’s just a matter of organizing things so that when you read their code you can match it with yours more easily.

No you’re not. I had to figure it out too because you didn’t have to in previous versions. And the default constructor was added automatically to the cpp file. Which now no longer is it seems. In my projects in previous engine versions the default constructor is not referenced in the header and it compiles.

Wow Thanks GregBlast!

I am really dumb :stuck_out_tongue:

Thanks again!

old “GENERATED_UCLASS_BODY” macro includes constructor definition, new “GENERATED_BODY” macro doesn’t.