Hey there,
i’m getting compile Error C2084 “Function ATank::ATank(void) already has a body” after I added Tank subclass.
I’m using Unreal 5.1.1 and this is my code:
Tank.h
// Fill out your copyright notice in the Description page of Project Settings.
#pragma once
#include "CoreMinimal.h"
#include "BasePawn.h"
#include "Tank.generated.h"
/**
*
*/
UCLASS()
class TOONTANKS_API ATank : public ABasePawn
{
GENERATED_BODY()
private:
UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category= "Toon Tanks", meta=(AllowPrivateAccess="true"))
class USpringArmComponent* SpringArm;
UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category= "Toon Tanks", meta=(AllowPrivateAccess="true"))
class UCameraComponent* Camera;
};
Tank.cpp
// Fill out your copyright notice in the Description page of Project Settings.
#include "Tank.h"
#include "Camera/CameraComponent.h"
#include "GameFramework/SpringArmComponent.h"
ATank::ATank()
{
SpringArm = CreateDefaultSubobject<USpringArmComponent>(TEXT("Spring Arm"));
SpringArm->SetupAttachment(RootComponent);
Camera = CreateDefaultSubobject<UCameraComponent>(TEXT("Camera"));
Camera->SetupAttachment(SpringArm);
}
Kinda hard to tell without seeing the full class (unless that’s it).
But it’s complaining that ATank::ATank() (classes constructor) has already been defined somewhere. Double check that somewhere in your code that ATank::ATank() isn’t being defined twice. You may have Another Tank class derived from ATank or something.