Forum rules - please read before posting.

Deleting an item from InventoryManager caused all arrangepuzzles to throw errors on clicking a piece

I one day randomly started getting errors whenever I clicked on a puzzle piece in either of my arrange puzzles:

NullReferenceException: Object reference not set to an instance of an object
AC.Downloads.ArrangingPuzzle.ArrangingPuzzleManager.OnInventorySelect (AC.InvItem invItem) (at Assets/AdventureCreator/Downloads/Arranging puzzle/Assets/Scripts/ArrangingPuzzleManager.cs:169)
AC.EventManager.Call_OnChangeInventory (AC.InvCollection invCollection, AC.InvInstance invInstance, AC.InventoryEventType inventoryEventType, System.Int32 amountOverride) (at Assets/AdventureCreator/Scripts/Managers/EventManager.cs:1704)
AC.RuntimeInventory.SelectItem (AC.InvInstance invInstance, AC.SelectItemMode _mode) (at Assets/AdventureCreator/Scripts/Inventory/RuntimeInventory.cs:216)
AC.InvInstance.Select (AC.SelectItemMode _selectItemMode) (at Assets/AdventureCreator/Scripts/Inventory/InvInstance.cs:240)
AC.Downloads.ArrangingPuzzle.ArrangingPuzzlePiece.Update () (at Assets/AdventureCreator/Downloads/Arranging puzzle/Assets/Scripts/ArrangingPuzzlePiece.cs:92)

This error leads to this code block, specifically the if statement throws the error:

private void OnInventorySelect (InvItem invItem)
{
foreach (ArrangingPuzzlePiece piece in pieces)
{
if (piece.AssociatedItemID == invItem.id)
{
KickStarter.cursorManager.inventoryHandling = InventoryHandling.DoNothing;
SelectedPiece = piece;
return;
}
}
}

This was strange since my puzzles had been working fine before and had not been touched directly. Walking back through version control, I realize the issue starts when I deleted an item from the Inventory Manager's Inventory Items list. I removed an item at ID 4 that I was cutting from the game, and somehow this broke both the puzzle that this item was a part of (I removed it from the puzzle appropriately as well), and broke another arrange puzzle that had nothing to do with this item. Any time an arrange puzzle piece is clicked on I now get this error instead.

What's going on here? How can I fix this? Does deleting an item from Inventorymanager always have the potential to break things?

Comments

  • From my experience, removing or changing inventory items IDs will result in the inventory item being removed in various parts of AC system.

    One place this happens is in the event window, where for example the Inventory select event will lose the reference to the inventory item.

    So this is what probably happened to you. I would go ahead and check all the places where you added inventory items references and set them back as you have it before

  • @dgames set them back as in try and re-add the item back in as it once was? I currently have a different item taking that ID but I can shift things if necessary. I don't understand why it is doing anything inventory related in the first place for an arrange puzzle.

  • The deletion of inventory items should have no bearing.

    When you did you grab the Arranging Puzzle template? Older versions of the template did have a dependency with the Inventory Manager, but that's no longer the case.

    Try backing up your project and then re-downloading and importing the package.

  • edited September 2024

    set them back as in try and re-add the item back in as it once was?

    if you are using one of those templates that can be downloaded from the downloads section I'm afraid figuring out where the inventory item got "unset" may be too difficult.

    The deletion of inventory items should have no bearing.

    not my experience, messing with the items in the inventory AC panel, will remove the inventory item in some parts of AC, like the Event window. Had this issue in the current version

  • The deletion of inventory items should have no bearing.

    To clarify: I'm only referring to the use of the Arranging Puzzle template. Removing items will cause issues with regular Actions that specifically reference them - but you can use the "Find references" button beside them to get a list of references made to them in your project beforehand.

    Items are referenced internally via their ID number, however, so removing an item shouldn't affect Actions that reference different items. If you're having an issue along these lines, please share details in a new thread.

  • The removal of the item should have no bearing, in that case.

    If this is the line throwing the error:

     if (piece.AssociatedItemID == invItem.id)
    

    could it be that the issue is with the piece variable instead? Check that the Arranging Puzzle Manager component's Pieces array has no empty objects.

  • Ah yes, there was in one of the arrange puzzles. Guess having an empty object in one puzzle broke both puzzles in the scene. They look like they're working now, Thanks!

  • No problem. I've updated the package to account for this.

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Welcome to the official forum for Adventure Creator.