[SOLVED] Access violation - code c0000005 (first/second chance not available)

That’s a null pointer crash. Likely your AddItemToInventoryByID is accessing a nullptr. If you’re using that code in the tutorial, I’d change it to this:



bool AInventoryController::AddItemToInventoryByID(FName ID)
{
**if (AInventoryGameState* GameState = Cast<AInventoryGameState>(GetWorld()->GetGameState()))**
    {
        UDataTable* ItemTable = GameState->GetItemDB();
        FInventoryItem* ItemToAdd = ItemTable->FindRow<FInventoryItem>(ID, "");

        if (ItemToAdd)
        {
            // If a Slot- or WeightLimit are not needed remove them in this line
            if (Inventory.Num() < InventorySlotLimit && GetInventoryWeight() + ItemToAdd->Weight <= InventoryWeightLimit)
            {
                Inventory.Add(*ItemToAdd);
                ReloadInventory();
                return true;
            }
        }
    }
    return false;
}


Likely whatever gamemode your level is using, isn’t the one you expect.