Lyra inventory system

Hi,

I’m trying to retrieve the actor stored in the quickbar (a weapon), I’ve tried with blueprints and C++. I need the actual actor spawned to give it to a framework to equip the item.

I can see the weapon being picked up at the spawner and added to the quickbar, but I can’t seem to retrieve the original actor object added to the inventory.

Could you help me figure a C++ or blueprint way to retrieve the actor (like the output of SpawnActor function) from the inventory ?

Blueprint:
Get component by class → Inventory manager → find first item stack by definition → I get the item in the form of a “Lyra Inventory Item Instance Object”

C++:
AActor* ULyraQuickBarComponent::GetFirstEquippedActor()
{
ULyraInventoryItemInstance* result = nullptr;
result = Slots[0];

AActor* actor = nullptr;
ULyraEquipmentInstance* inst = EquippedItem.Get();
if (inst != nullptr) {
	TArray<AActor*, FDefaultAllocator> actors = inst->GetSpawnedActors();
	if (sizeof actors > 0) {
		printf("Actors: " + sizeof actors);
		actor = actors[0];
	}
	else {
		printf("Actors is empty");
	}
}
else {
	printf("Equipped Item is null");
}

return actor;

}

Thanks !

Problem was not the code, problem was that the equipment manager was not setup in the plugin definition => silent failure of null exception of the equip method in the C++ => no object to retrieve.

1 Like