Spawning an Actor from an Array(Inventory)

I want to spawn an Item from my inventory. Only problem is I have no clue on how to make this happen.

	/** Items in inventory */
	UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = Inventory)
		TArray<class AItem*> Inventory;

that’s what I have for my Inventory. I am able to add items in it. Not a problem. but when I want to spawn them, It requires a TSubclassOf. Is there a way to convert my Item class to be a TSubclassOf when casting it?

void ASpecialCharacter::EquipWeapon(AWeapon* Weapon)
{
	if (Weapon)
	{
		FVector Loc = Mesh->GetSocketLocation("Weapon_Socket");
		FRotator Rot = Mesh->GetSocketRotation("Weapon_Socket");
		FActorSpawnParameters SpawnParams;
		SpawnParams.Owner = this;
		SpawnParams.Instigator = Instigator;
		AWeapon *WeaponSpawn = GetWorld()->SpawnActor<AWeapon>(Weapon,Loc,Rot,SpawnParams); // THIS LINE DOESNT WORK
		
	}
}

this is what I am trying to use to spawn the particular actor(AWeapon is inherited from AItem). and the error I get is it’s telling it cannot convert arguement 1: AWeapon to UClass.

//.h
        UPROPERTY(EditDefaultsOnly, Category = Weapon)
	class AWeapon* WeaponSelect;

//.cpp

void ASpecialCharacter::OnSelectWeapon()
{
	if(WeaponSelect)
	{
		EquipWeapon(WeaponSelect);
	}
}

another thing, I did a simple collision check and made the collision be the WeaponSelect when collided into. But still, gives me the same error.
Anyone have any idea???

If you really, want to get class of object which can be used with SpawnActor, you can use:

AMyActor->GetClass();

But I’m not sure if it wouldn’t be just better to create array which would store

TSubclassOf<AMyActor>

And from that pick your actor and store it. Why do you want to store already created objects in Array and then spawn another copy of them ?
If items in your inventory doesn’t do anything (like responding to incoming events, ticking, or even just rendering in world), there is no reason to store them as objects.

If your items have certain properties (like character attributes), you might consider wrapping them into USTRUCT() which will contain attributes and TSubclassOf for spawning purposes.

Reason I want to do this is because I wish to equip the weapon from the inventory. When I pick up an item with C++ in collisions, I can’t make them a TSubclassOf when checking for the colliding actor. Thus why I needed to know :-(. I would spawn the actor just to equip the weapon. Where the ammo and what not would be stored elsewhere.