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 Rhylvin2015 · Jun 18, 2015 at 06:22 AM · instantiatesaveheirarchy

how do you save an instantiated object in the heirarchy. meaning when i unpause the game its still there.

hello, ive been stumped on this problem. I need to save this object (some kind of Highscore Line) where when the player dies. it leaves an object(Highscore Line) and so when i restart the game or unpause and play it again the instanitated object(Highscore Line) would be still there? Instantiate(HighScoreLine,new Vector3(Player.position.x,0,0),Quaternion.identity);

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
2
Best Answer

Answer by KayelGee · Jun 18, 2015 at 01:15 PM

There are multiple options. The easiest would be to save each death to a file on your pc and when you start your game you read that file and instantiate objects with that information.

A little more complex solution would be to setup a database and save deaths into it and loading from it at the start of the game again. This solution would make sense if you want the deaths of all your players to be visible to all players.

However you do it the principle will be the same. You save your data somewhere in someway and load it at game start.

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 XenonSpher · Jun 18, 2015 at 03:25 PM 0
Share

Im sorry but my question wasn't clear. my game is a 2d infinite runner running in the right side. I need to save that object even without pausing the editor. my purpose is to create some kind of finish line (the object)that would be instantiated on the position when you first die with your first highscore. so when I click the restart button. the next time i will get closer to the first high score i got would have a finish line on it and the player would break that finish line telling the player that he beat his previous highscore. and when he dies again that would instantiate another finish line on the spot that he died Instantiate(HighScoreLine,new Vector3(Player.position.x,0,0),Quaternion.identity);

so i need some kind of method. that would do that for me without unpausing the editor. im really sorry sir

avatar image Dave-Carlile · Jun 18, 2015 at 03:31 PM 1
Share

It's effectively the same answer. Just save the high score somewhere and load it when the game starts. PlayerPrefs is a good place for that. You should know where a particular score shows up in your game progress, so you can insantiate the finish line at that position based on the score.

avatar image
0

Answer by rhbrr5hrfgdfgw · Jun 18, 2015 at 03:42 PM

I have an idea, you can save an integer(PlayerPrefs) and when you die and you are above high score

     if(dead && score > highScore){
     //Save the integer with playerprefs
     }

and then every time you start the game you can instantiate using the integer you saved. You might have some problems since the integer value isn't like x value but thats a nice start to the code.

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

4 People are following this question.

avatar image avatar image avatar image avatar image

Related Questions

Terrain: Use as scenario (individual) and prefab (unchanged, reusable) 0 Answers

Objects instantiated in custom editor not saving. 0 Answers

How do you make a script that creates a new scene on runtime? 1 Answer

Avoid altering prefab at runtime 1 Answer

Instantiate + Coroutine = problem 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