How do you instantiate a notplacable actor?

I’m creating an NotPlacable Inventory class that derives from AActor and i want my custom ACharacter to have an instance of that class. Since it’s an actor i tried to to spawn it on PostInitializeComponents() using:

FActorSpawnParameters SpawnInfo;
SpawnInfo.bNoCollisionFail = true;

Inventory = GetWorld()->SpawnActor<AInventory>(AInventory::StaticClass(), SpawnInfo);

That’s giving me NULL. O also tried (don’t know exactly what this does, saw it online):

Inventory = AInventory::StaticClass()->GetDefaultObject<AInventory>();

But it’s still giving me NULL. Do you know what i am doing wrong? I’m assuming that on Unreal Engine we’re not supposed to instantiate AActor custom classes with new or mallocs, so i don’t see other options other than the one’s i’ve mentioned.

Your code with SpawnActor is correct, but you shouldn’t really need the bNoCollisionFail, we usually spawn those with just SpawnActor(Class). We do this all the time in fortnite. You generally want your non-physical actor to derive directly from AActor.

My guess is that something in your actor properties is stopping it from spawning, such as a physical component. You should step into SpawnActor and see why it’s failing.

Yes i agree that the bNoCollisionFail does not make much sense, since it’s a non-physical actor. I will look into that and try to see what is happening and will comment here when i know something. Thank you very much.