- Home /
Simple way to reset GameObjects?
Hi, here's my problem: In my program, I'd like to be able to return all GameObjects to their initial positions. My solution is to create a script with references to every GameObject, get their current values and store them as variables, and, when prompted, return all Gameobjects to said values. This seems a bit excessive. Is there a better way to do this? Thanks in advance.
Can't you just reload the scene? If there is data to be preserved, you can use DontDestoryOnLoad().
I do not see anything "excessive" in this. That's how program$$anonymous$$g works. You tell the computer what to do and it will be done if you don't make mistakes :) There is no magic formula for your script to "know" your initial positions. Except when you Instantiate all your objects from script code (ins$$anonymous$$d of having them put into the Scene manually). Then your code deter$$anonymous$$es the positions (or they are defined in the Prefabs) and you could reset them like you have created them (or Destroy and re-Instantiate them).
Your answer
Follow this Question
Related Questions
Reset Transform.position 1 Answer
Camera object remember position after scene reload 0 Answers
store positions in array 1 Answer