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.