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 ROOKIE · Dec 31, 2011 at 12:19 AM · positionsceneload

Swapping between Scenes without affecting objects position.

How can I have object appear at the same position as it was before i swapped between two levels?

Lets say in level 1 I have cube in the middle of Scene, I push it into corner and load level 2. Then I come back (load) level 1 but the cube appears back in middle.

I appreciate any suggestions.

Comment
Add comment
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

2 Replies

· Add your reply
  • Sort: 
avatar image
1

Answer by Silverfell 1 · Dec 31, 2011 at 12:35 AM

There are (at least) two ways of doing what you need:

  1. http://unity3d.com/support/documentation/ScriptReference/Object.DontDestroyOnLoad.html <- setting this in the Awake() (or whatever) function of your object will make it persistent through scene loads/changes. Just bear in mind that you'll have to manually destroy it when you want it gone.

  2. Save the object's coordinates, and reset them when the scene loads again.

Either method requires a little extra coding, but neither really is very hard :)

Comment
Add comment · Show 1 · 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 Lo0NuhtiK · Dec 31, 2011 at 03:22 AM 1
Share

@ROO$$anonymous$$IE : you should move the comment you posted in an answer post, to a comment post. -- Did you notice @Silverfell 1 2nd option ? ... Take a look at @aldonaletto answer in this other topic How to save an instantiated object , and also check out this -> PlayerPrefsX maybe those will help.

avatar image
0

Answer by ROOKIE · Dec 31, 2011 at 02:51 AM

I forgot to mention that I am using DontDestroyOnLoad. The only problem I have with that is that when I return to first Scene it positions the object into its default position and not the one I left it in.

To make more sense of it - it is like if I had chair in the middle of room#1 and I moved it into corner, then left into room#2 for a second and then went back into room#1 and finding the chair back in middle of room instead in corner where I left it. I would either think that I am going crazy or I have ghosts in my house.

Thanks for the reply though.

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

6 People are following this question.

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

Related Questions

Load Custom Scene 2 Answers

Anyway to save which seen the player was on, then load that scene back from another one at a different time? 2 Answers

Help with Object position and state, save and load. 1 Answer

Load Scene by audio clip 2 Answers

Substances rendering slowly after level start. 0 Answers


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