I have objects at specific locations in my scene. When I play the scene those objects move as expected. However, when I stop play and return to the scene editor, the objects are now in whatever position they ended in. Why would it be that way? Shouldn’t the scene objects reset to where I put them in the editor?
That’s weird. The only possibility I can think for that to happen is if you are handling not the gameobject, but the prefab; that’d explain the objects keep the final “play” position.
But it sure doesn’t looks like that, based on your foreach. If you’re running this code in a “enemies parent”, a transform that contains all the enemies, you can try to replace your code with something like:
foreach(Enemy enemy in GetComponents<Enemy>())
//Do your thing here
Let me know if it helped!
OK, I’m pretty sure the cause was a leftover ExecuteInEditMode attribute in a base class that also happened to be completely unnecessary. It was executing the Start method in the editor before it executed it in the player, thus doubling up the initial movement and applying it to the editor. Once the base class was removed it works fine. Thanks for the suggestions though. Stuff like this makes me think I’m going crazy.