Overloading Constructors

So this is me coming from a background with Unity3D and C#/.NET. I am trying to port over some code of a project and I noticed that I have this terrible habit of using constructors and overloading them a few times. Trying to do almost the same thing does not appear to want to work, mostly due to the framework of the engine from what I can tell.

The default constructor in the .cpp file I left alone, but trying to make another constructor right below it didn’t work for me like it normally would in C#. Let’s say for example I was trying to make a circle:

//Circle.h
#include "GameFramework/Actor.h"
#include "UnrealMathUtility.h"
#include "Circle.generated.h"

UCLASS()
class ACircle : public AActor
{
	GENERATED_UCLASS_BODY()

public:
	UPROPERTY()
	FVector Focus;
	UPROPERTY()
	float radius;
};

//Circle.cpp
#include "UnrealTeralta.h"
#include "Circle.h"


ACircle::ACircle(const class FPostConstructInitializeProperties& PCIP)
	: Super(PCIP)
{    	
}    
ACircle::ACircle(FVector Position, float radiusLength)
{
    Focus = Position;
    radius = radiusLength;
}

Attempting to do this circle even doesn’t work for me. I owe it up to my complete unfamiliarity with the engine and slight unfamiliarity with C++. I’m wondering if even what I’m trying to do is appropriate for using the Unreal macros.

For the curious, my purpose is not to “spawn” these objects in the editor (as most of these questions seem to want to do), just set the data up with the actor ready to be spawned in at a moment’s notice. I appreciate your patience with me.

#BeginPlay()

Override AActor::BeginPlay() instead!

virtual void BeginPlay() OVERRIDE; 

It runs after all BP settings have also been set, unlike the constructor.

BeginPlay() is also used more than PostInitComponents, which does not run for StaticMeshActors

Enjoy!

Rama

So, I too also tried overloading constructors, but I don’t think unreal allows you to do that since all the classes are already set for you, but I might be wrong, however you can easily overcome this by making a function to initialize your variables.

//Circle.h
//under public make a function for your initialization
UFUNCTION()
void init(FVector Position, float radiusLength);

//Circle.cpp
void ACircle::init(FVector Position, float radiusLength)
{
	Focus = Position;
	radius = radiusLength;
}

so when you create your a new instance of your class somewhere, just use init underneath, hope this helps mate!

Thanks for your help. I’ll have to try it out once I get some more experience with it and understand what it is used for exactly. I’m still kind of in my exploration phase with Unreal Engine.

I was afraid that I’d have to do this. Oh well. It appears to be a matter of whether or not you want editor/engine functionality or code functionality more. Thank you for your help.