OK that worked (to a great extent), but I noticed a new problem… and a bug (which is just natural evolution from what we did):
[PROBLEM]
if you exit the game and don’t finish mining the rock or cutting the tree and return, then to the game you didn’t even begin harvesting. I think we didn’t add that to the saving system.
So let’s assume we mined 5 out of the 10 resources available, and quit the game and returned, to the game you didn’t mine anything last time, so now you got 10 resources available (although you should only be having 5 left)
[BUG]
This one is hard to explain, but I’ll try my best:
Occasionally (THAT"S THE BIG PROBLEM, IT’S OCCASIONAL), the rock that respawns when we return to a load scene will not be detected by the targeter that Brian created for our third person transition, so the error we previously had that was solved by creating an event (check the chat above) in ‘ResourceGathering.cs’ and subscribing to it is suddenly back… I don’t know how or why, but it’s there again (it’s the exact same problem me and Brian were trying to solve prior to the Saving System)
here’s the first NRE (when I hit the mapped key):
MissingReferenceException: The object of type 'ResourceGathering' has been destroyed but you are still trying to access it.
Your script should either check if it is null or you should not destroy the object.
RPG.Core.RangeFinder`1[T].FindNearestTarget () (at Assets/Project Backup/Scripts/Core/RangeFinder.cs:56)
RPG.States.Player.PlayerFreeLookState.InputReader_HandleResourceGatheringEvent () (at Assets/Project Backup/Scripts/State Machines/Player/PlayerFreeLookState.cs:136)
RPG.InputReading.InputReader.OnInteractWithResource (UnityEngine.InputSystem.InputAction+CallbackContext context) (at Assets/Project Backup/Scripts/Input Controls/InputReader.cs:176)
UnityEngine.InputSystem.Utilities.DelegateHelpers.InvokeCallbacksSafe[TValue] (UnityEngine.InputSystem.Utilities.CallbackArray`1[System.Action`1[TValue]]& callbacks, TValue argument, System.String callbackName, System.Object context) (at Library/PackageCache/com.unity.inputsystem@1.7.0/InputSystem/Utilities/DelegateHelpers.cs:46)
UnityEngine.InputSystem.LowLevel.<>c__DisplayClass7_0:<set_onUpdate>b__0(NativeInputUpdateType, NativeInputEventBuffer*)
UnityEngineInternal.Input.NativeInputSystem:NotifyUpdate(NativeInputUpdateType, IntPtr)
and the second one:
MissingReferenceException while executing 'performed' callbacks of 'Player/InteractWithResource[/Keyboard/u]'
UnityEngine.InputSystem.LowLevel.NativeInputRuntime/<>c__DisplayClass7_0:<set_onUpdate>b__0 (UnityEngineInternal.Input.NativeInputUpdateType,UnityEngineInternal.Input.NativeInputEventBuffer*)
UnityEngineInternal.Input.NativeInputSystem:NotifyUpdate (UnityEngineInternal.Input.NativeInputUpdateType,intptr)