Item Transfer Update and Expansion


Hello again!


After a few new changes to how things worked with the item transfer system I learned that there's quite a few flaws and clashing of how some systems functioned that resulted in the game breaking and the player generally being soft-locked in the ship. The biggest flaw that send me back into the inner workings of this script was the new ways Items were handled in the players inventory. Originally the Inventory system would destroy the item and use a scriptable object and prefab to re-create it. We realized this would cause issues for things such as carrying over unique data, displaying the item in the players hand, and destroying objects before we're done with them is a recipe for "Null Exception Errors" galore. So the system was updated to a disable/enable and teleport system. However, one thing the original system was very good at handling items in the inventory between scenes since the object itself was deleted with the data attached to the player which already was programmed never to be deleted. Another issue is that with the item disabled and being immediately teleported out before being reenabled the transfer box never reported that it left the box which means that items the player dropped in the box and took out would now continue to persist regardless of if they should or not.

So the system had to change, and it also revealed a few other cases during testing which would cause the program to glitch and force the Game Manager to halt it's current actions - which included opening the ship. One notable case that was discovered was objects spawned with our Loot Generator. The script had nothing to handle parented objects, and by default a parented object cannot be modified without removing it from the parent. So when the system attempted to transfer the item to the DontDestroyOnLoad scene the game would assume the action happened, and move on even though the object still existed in memory that'd be destroyed.  So when the scene transferred and the Game Manager attempted to call to said object it would find a deleted object and halt it's process. 

To remedy these issues a few new updates were put in place to the systems to help them cooperate better. First and foremost there are now - yet untested due to patching the other issues - checks in place before the Game Manager will attempt to modify an object after a transfer. Whilst items might not behave as they should their misbehavior should no longer take down the entire GM anymore. To fix the parenting issue the fix was very simple: Just don't create the object as a child of the spawn points. I wasn't even aware the game was doing this until items mysteriously stopped transferring when spawned in. Next there was the inventory issue. To remedy this one the game now treats the players Interaction with items as putting the item in the collection box. It'll add it to the Game Managers list and put it in the DDOL Scene, and the inverse is now true when the player drops anything. The game will run the script to remove an item from collection, and if the player drops it within the collection zone again because the item would be touching the zone again the transfer zone will report the item as collected. I'm sure I've missed a few cases in which the Game Manager loses track of the object, but that's for future me to solve and report on. 


Hopefully next we speak about a problem/solution it's a different system, but the other systems are being difficult and don't quite have the solution yet.

Until next time. 

Leave a comment

Log in with itch.io to leave a comment.