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 RDamery · Nov 20, 2012 at 10:47 PM · scenedatabaseworld

how do i make a script that records where a player was before entering another room

For instance, if I'm currently on the world scene and I am in the village "Some Village" I go near a house door and enter the house scene. I can walk around a bit and explore the scene and, once I get out the house scene the player should be outside the house he was just in and not some other place, my question is what script can I use to accomplish this?

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 AlucardJay · Nov 21, 2012 at 05:35 AM 1
Share

Check my answer here : http://answers.unity3d.com/questions/237485/change-position-of-camera-on-scene-load.html

And deploy the singleton method in the comments. Let me know if this is confusing =]

the basic principle is (1) use PlayerPrefs; or (2) use a singleton with DontDestroyOnLoad.

more on singleton : http://answers.unity3d.com/questions/11314/audio-or-music-to-continue-playing-between-scene-c.html

http://wiki.unity3d.com/index.php?title=Singleton : http://www.dotnetperls.com/singleton-static

avatar image RDamery · Nov 26, 2012 at 04:02 AM 0
Share

Haha sorry I don't get it

avatar image MrDude · Nov 26, 2012 at 04:19 AM 0
Share

To keep it simple, this is one way you could do it... function BeforeEntering() { playerPrefs.SetFloat("pposx", transform.position.x); playerPrefs.SetFloat("pposy", transform.position.y); playerPrefs.SetFloat("pposy", transform.position.z); }

function AfterExitting() { transform.position.x = playerPrefs.GetFloat("pposx"); transform.position.y = playerPrefs.GetFloat("pposy"); transform.position.z = playerPrefs.GetFloat("pposz"); }

avatar image RDamery · Nov 26, 2012 at 04:43 PM 0
Share

Thanks man! That worked :), It was easier to understand this explanation than the others :D

0 Replies

· Add your reply
  • Sort: 

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

11 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

Related Questions

Connection between menu and scene 2 Answers

Is it possible to get terrain tools on imported terrrain ? 1 Answer

Change from one scene to another 0 Answers

Database and transferring variables 1 Answer

How do you make a script that creates a new scene on runtime? 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