Spawning actor problem, but still accessable?

I created an equipment class that I’m trying to spawn in a character’s inventory. I setup the inventory via an inventory initialize function on the character:

//Initialize player equipment, check for first weapon, then set it as default current weapon
void ADefaultCharacter::InitializeEquipment()
{
	UWorld* const World = GetWorld();
	bool bFoundFirstWeapon = false;
	AEquipment* NewEquipment;

	if (World)
	{
		for (int i = 0; i < MaxEquipmentSlots; i++)
		{
			NewEquipment = GetWorld()->SpawnActor<AEquipment>(AEquipment::StaticClass());
			EquipmentInventory[i]= NewEquipment;

			checkf(EquipmentInventory[i], TEXT("FOUND AN INVENTORY ENTRY THAT POINTS TO NOTHING!"));
			GEngine->AddOnScreenDebugMessage(-1, 5, FColor::Green, FString::FromInt(i));

			//If this new item is a weapon, set the current weapon
			if (!bFoundFirstWeapon)
			{
				print("Checking if the item is a weapon");

				if (NewEquipment->IsWeapon())
				{
					print("Found a weapon");
					bFoundFirstWeapon = true;
					SetCurrentWeapon(NewEquipment);
				}
			}
		}
	}
	
	if (!bFoundFirstWeapon)
	{
		print("First weapon wasn't found during initialization. Something's wrong.");
	}
}

This compiles fine, supposedly fills the inventory array with something (not instances of equipment references?), but informs me that no current weapon is set. This is despite that fact that all equipment items currently just use default values, including the value that IsWeapon() returns (should be true), and therefore should set the current weapon after the first item is created. Even more perplexing, despite current weapon never being set, I can still call equipment functions, like CurrentWeapon->UseMainAttack(), successfully.

I’ve referenced the shooter project and looked at similar problems, but I just can’t figure it out. I’m still new to c++, but I assume I’m doing something wrong when I’m spawning the equipment actor…? A field I need to specify, perhaps?

I can’t tell what is happening in your program from your description of what occurs. What gets printed? What’s happening? Your description of what is happening is a bit too vague, so I think you’ll need to describe what gets printed from those messages, etc.

I found the problem: when I set the default for the boolean value that determines whether or not the item is a weapon in Equipment.cpp, I’d mistakenly put “bool bIsWeapon = true;”. This, of course, doesn’t cause any errors when compiling, so I hadn’t noticed it. Removing “bool” fixed it and everything now works as expected. A stupid mistake, to be sure.

Thanks for taking a look at the question. Though I found my own issue, your comment pointed out my need to write clearer questions in the future.