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 Boog1eMan · Oct 24, 2012 at 09:03 PM · loadleveltransfer

Loading a level. (Few questions)

I made a cave into my game and put a teleport trigger to get inside the cave. I realized that, if I want the game to work properly without lagg, I need to make a new scene for the cave.

When i load use Application.Loadlevel("Cave01");
1. If my character has for example 70/100 health and some equipment equipped + stuff in his inventory. How do i transfer all that stuff to the cave scene.
2. Same thing but with eg movement scripts. Can I somehow put the character related stuff to be "global" so that it saves between scenes?

Haven't actually made the inventory scripts or health scripts yet, but I would like to know this stuff in advance, before moving forward. Thanx for the help!

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

1 Reply

· Add your reply
  • Sort: 
avatar image
1
Best Answer

Answer by Seth-Bergman · Oct 24, 2012 at 09:34 PM

1: OK, basically you can use DontDestroyOnLoad to keep your player's stats intact

2: Global may not be quite what you want, that refers to SCOPE, but what you are reaching for is STATIC.. You can make vars static (global) to keep them from resetting, but.. Be AWARE, making your data members static means there is only one instance of that var across all scripts, so it retains it's value from one script instance to another, but in the case of a player status script, that's what you want anyway..

for example:

 var score : int;  // resets on load
 static var score : int;  // will retain its value between scenes (one value across all instances)



Comment
Add comment · Show 2 · 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 Seth-Bergman · Oct 24, 2012 at 09:37 PM 0
Share

By the way, please don't post responses to answers as new answers, you can use the comment field for that.. And if an answer helps you, mark it as accepted! (the check mark) And Welcome to the forum!

avatar image Boog1eMan · Oct 25, 2012 at 08:00 AM 1
Share

Ah, okay thanx. That helped a lot. Where is the accept button? Can't seem to find it. nvm found it.

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

10 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

Related Questions

Application load advanced loading NO EXPERIENCE 2 Answers

Loading a level on contact 2 Answers

Load Level when Key is pressed 2 Answers

level loader script wont work 1 Answer

Load a scene/level when enemy is close... 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