I apologize in advance, but I’m very new to Unity and I’m very bad at programming. I’m sure the answer to this question is obvious, but I’ve been staring at it for too long now and I think the answer is just outside my range of knowledge.
I created two food bins for a scene in my game. Each food bin contains a sprite of food that moves down on the Y axis at 2 different points throughout the day (9am & 1pm). So far I’ve succeeded in making the food items move down the Y coordinate when those times of day are reached.
Here’s my issue:
I need to save the position of the food items in each bin so that the position can be reloaded if the player exits the building scene to the overworld, then re-enters the buildings scene. The problem that I’m having is that I can’t seem to figure out how to save and reload the position of the food items appropriately.
If you watch this recording you will see the food in “test bin 1” (the red food) remains in the appropriate transform position between scene loads. However, the brown / tan colored food in “test bin 2” moves to the same SavePosition as the red food from “test bin 1” after the player exits and re-enters the scene. You’ll see around ~1 minute in to the video if I hide the “test bin 1” sprites the food from test bin 2 is hiding underneath it after the scene reloads.
Can anyone provide me with some insight in how I might be able to go about fixing this?
I can see that FoodManager.SavePosition is being set at 2 different points in my console log, but I think only 1 of those positions is being loaded at the top of Update().
I’ve attached a screenshot of relevant scrips + a link to a video recording.
Thank you so much to anyone who can point me in the right direction.