I am running into problem with my code. The spawnactor function always return a nullptr. I have tried called it in both BeginPlay and other function and both gave me an nullptr error.
Header file
UPROPERTY()
class AShield* PlayerShield;
UPROPERTY();
TSubclassOf<class AShield> ShieldClass;
Usually there’s something in the output logs that will explain why… Such as, a collision at the SpawnPoint, etc. The UE Output logs will says something about why it can’t spawn the actor.
If there truly isn’t anything in the logs explaining why you’ll have to step through UWorld::SpawnActor to find the reason.
It can be helpful to temporarily set your solution configuration to “DebugGame Editor”. You can debug without a bunch of optimizations making the instruction pointer jump all over the place. (But check the logs, I’d wager the cause is right there in the output logs.)