Look at this mess! Who's going to clean it up? The employees of course!
But uh...I don't have any employees. Really not sure how to make any. But I know if I want to start testing this game I need product on the shelves. And it doesn't take long to make a mess of this place.
Sooo, I decided to create a simple clean up script.
When the game starts, every product detects its current transform location in the game world. It then checks to see if its transform location changes. When that happens, it starts a timer (that can be set in editor) and once that timer is up, the product zips back to its original location.
But uh...I had trouble.
So while products were returning to their initial location, they were also returning at really strange angles. One even returned to its spot while spinning in space. It was kinda cool, in a trippy way--just not what I needed.
So I took my confusion onto Unity Answers and to my surprise, someone kindly answered. Their Username is Dolzen (not sure if it's polite to share). They gave me exactly what I needed to make the objects return to their spot, and at the right angle.
The Script:
And this is how it works:
Ultimately, I would like the items to return to shelves when the player isn't looking. I'm not 100% how that should work. But I would like an NPC Employee to be there to imply they put everything back. Maybe they can say something snarky to the player as well.
Now that I'm caught up on the progress of FP$, I need to start making more progress.

No comments:
Post a Comment