Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by reallybadgame · Apr 11, 2014 at 06:09 PM · movementeditorobjectsceneplay

Why does object movement get saved to scene editor?

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?

Comment
Add comment · Show 4
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image robertbu · Apr 11, 2014 at 06:11 PM 0
Share

Can we see your script for one of the moved objects?

avatar image reallybadgame · Apr 11, 2014 at 06:21 PM 0
Share
         foreach (GameObject enemyObject in GameObject.FindGameObjectsWithTag("Enemy"))
         {
             Vector3 startPos = enemyObject.transform.position;
 
             Enemy enemy = enemyObject.GetComponent<Enemy>();
             enemy.path.Add(startPos);
 
             enemyObject.transform.position = (startPos.normalized * 10.0f) + startPos;
         }

It basically disperses the enemies then sets a path for them to return to their starting position.

avatar image robertbu · Apr 11, 2014 at 06:22 PM 0
Share

The objects should reset, and I cannot think of a scenario rather than a bug in Unity that would cause them to save their moved position.

avatar image reallybadgame · Apr 11, 2014 at 06:26 PM 0
Share

Yeah, I'm at a loss. It's almost funny. With each run the objects in the scene are beco$$anonymous$$g more dispersed. Sometimes it seems like they go back to where they were last time, but it's very hard to tell at this point. I guess I'll keep hitting it with a hammer until it works.

2 Replies

· Add your reply
  • Sort: 
avatar image
0

Answer by nicolasjr · Apr 11, 2014 at 06:29 PM

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!

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image
0

Answer by reallybadgame · Apr 12, 2014 at 01:18 AM

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.

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

22 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Scroll horiz and vertically faster with arrows in scene 1 Answer

Camera behavior the same as the unity editor has 2 Answers

Move objects in scene view before running the game 0 Answers

Changing master view move speed. 3 Answers

Unity 5 editor set play width and height in pixels 1 Answer


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges