Why do I get a crash when running a function called by a timer?

I’ve been getting some crashes when I set a timer, and call a non-empty function. It doesn’t seem to matter much what I put into the function. I set the timer in the constructor:

ABomb::ABomb(const class FPostConstructInitializeProperties& PCIP): Super(PCIP) {
	GetWorldTimerManager().SetTimer(this, &ABomb::Explode, 5.0f, false);

void ABomb::Explode() {
	GEngine->AddOnScreenDebugMessage(-1, 5.0f, FColor::Red, TEXT("Boom!"));

Then, whenever I run the editor, it instantly crashes.

I have no idea what I’m doing wrong. It seems fairly simple, so I don’t know what more I can tell you.

I think it’s because you are starting the timer in the constructor of your ABomb object.

Try starting the timer in the function PostInitializeComponents(). It should work then.

PostInitializeComponents is called immediately after the components of your object have been set up.

Thank you very much.