Cannot spawn an actor from class

Hello.
I’m trying to make a simple inventory system and right now I want to implement item dropping.
This is my code:

    		if (PlayerInventory.Last() == "Item Zero")
    		{
    			GEngine->AddOnScreenDebugMessage(-1, 5, FColor::Red, FString::Printf(TEXT("Dropped Item Zero")));
    			FActorSpawnParameters DropParams;
    			DropParams.Owner = this;
    			DropParams.Instigator = Instigator;
    			AItemZero* const DroppedItem = World->SpawnActor<AItemZero>(ItemZeroDrop, PlayerCamera->GetComponentLocation(), PlayerCamera->GetComponentRotation(), DropParams);
    			PlayerInventory.Pop();
    		}

and the “ItemZeroDrop” is

	TSubclassOf<class AItemZero> ItemZeroDrop;

The code compiles without errors, but it doesn’t work.
When I press Q (which is the key for dropping items) I can see the message “Dropped Item Zero”, but no actors spawn.

If you know why, then please help.

Maybe you just don’t see it, because you are spawning it directly inside your head ?

I would insert a AddOnScreenDebugMessage(…) inside my AItemZero tick, which simply tells me, if it is existing.

Note: Inside tick setting the time to 0.0001 works best for me.

No, it’s not spawning at all, the number of currently existing actors in the level doesn’t increase…

I got to assume one of your refferences is invalid. Are you sure you assigned ItemZeroDrop a Class? Its a Placeholder but its empty by default.

You can check in a if statement if World and ItemZeroDrop actually Point to something before trying to Spawn. You can also verify if the Spawn was successful or returned you a nullptr (failed to spawn)

So I actually looked at one of my old codes and you were right.
Thanks for your answer.