[C++] editor aborts at FObjectInitializer::Get()

Hello,

I’m having a lot of trouble getting the behavior I want. What ends up happening is an abort gets triggered instead.

Here is the the last non assembly line called

UWorld(const FObjectInitializer& ObjectInitializer = FObjectInitializer::Get());

Which gets called by APSAbility

when the following code is called in PSCharacter

 if (PrimAug != nullptr)
 {
        PrimAug->OnUse();
 }

And here is where I get the pointer to PrimAug in PSCharacter::PostInitializeComponents()

 if (PrimAugClass != NULL)
    {
        FActorSpawnParameters SpawnParameters = FActorSpawnParameters();
        SpawnParameters.bAllowDuringConstructionScript = true;
        SpawnParameters.bNoFail = true;
        SpawnParameters.Instigator = Instigator;
        SpawnParameters.Name = TEXT("PrimaryAugmentation");
        SpawnParameters.Owner = this;
        SpawnParameters.Template = NULL; 
        
        PrimAug = GetWorld()->SpawnActor<APSAbility>(  PrimAugClass
                                                                                       , SpawnParameters
                                                                                       );
    }

The signature for APSAbility’s constructor

APSAbility::APSAbility()
: CDDuration(10.f)
, bOnCD(false)
{}

And the relevant data members of PSCharacter:

/** AugmentationOne class */
    UPROPERTY(EditDefaultsOnly, Category=Abilities)
    TSubclassOf<class APSAbility> PrimAugClass;
    class APSAbility* PrimAug;

The idea is I in different BP instance of PSChar I will set different classes which implement different abilities, but use the

APSAbility::OnUse()

As a common interface to call the abilities.
If you need any more info please let me know. I’d really like to get this working.

Thanks,

It would be helpful if you post your call stack here. Likely you are compiling in optimized version. To ensure absolute non-optimization, use

#pragma optimize("", off)

and make sure you put this at the top of your CPP. If you intent to use this in your header, make sure you have

#pragma optimize("", on)

at the bottom so this way anything including your header doesn’t get un-optimized by accident. You may also try to compile “Debug _____” build to see if it is okay to debug. Without optimization, you get a clearer picture of what’s going on.

The error was in on use where I had

UWorld World;

What was needed was:

UWorld* World = GetWorld();