UParticleSystem* => nullptr?!?

Hello everyone,

I already created an actor which spawns an attached particle a few weeks ago.
However, I cannot get it working anymore and I don’t know what I am doing wrong…
The solution is probably stupidly obvious, but… yea…

Alright, so here is the example:


MyActor.h

#pragma once

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

UCLASS()
class MYGAME_API AMyActor : public AActor
{
	GENERATED_BODY()

public:
	AMyActor(const FObjectInitializer& ObjectInitializer);

	UPROPERTY(EditDefaultsOnly)
	UParticleSystem* SomeParticle;	
};

MyActor.cpp

#include "MyGame.h"
#include "MyActor.h"

AMyActor::AMyActor(const FObjectInitializer& ObjectInitializer)
	: Super(ObjectInitializer)
{
	if (SomeParticle == nullptr)
	{
		UE_LOG(Log, Warning, TEXT("SomeParticle is a nullptr"));
	}
}

I then create a blueprint based on that class and set ParticleSystem…
However - SomeParticle is always a null pointer, no matter what I try to do.
This is soo ridiculous, especially because I got this working before…

(I’m sorry if the question is too stupid…)

The object initializer ctor is just for that to initializing the object itself, to get to the point to do some post work after BP has initialized the object try hooking your code in PostInitializeComponents, or in BeginPlay for runtime stuff.

In UE4 C++ constructor is only used to set default properties, you should not use it for gameplay code and you should relay on it to get any data about object (other then set default properties in constructor) because object is initiated at that point. UE4 reflections system and memory management do some magic after constructor, for example applying default/details propeties set in editor, you can’t access those before PostInitProperties() event is called but remember not everything is initiated yet at that point so you better use PostInitializeComponents (for both editor and gameplay) or BeginPlay (gameplay only)

Isn’t that just what I said in the comment?