Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 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 ad48 · Aug 06, 2011 at 01:06 PM · savecheckpoint

If Dead,Checkpoint and reset

Checkpoint script:

function OnTriggerEnter(col : Collider) {

if(col.gameObject.tag == "Player")

col.GetComponent(MyEnd).checkpoint = transform;

}

MyEnd script:

var checkpoint : Transform;

function MyRightEnd() {

transform.position = checkpoint.position;

//All then changes not save

}

How load checkpoint,but then changes not save?

Comment
Add comment · Show 1
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 FLASHDENMARK · Aug 06, 2011 at 01:41 PM 0
Share

I am not sure I follow. Please elaborate what you are trying to achieve.

2 Replies

· Add your reply
  • Sort: 
avatar image
0

Answer by Rydrako · Aug 06, 2011 at 02:03 PM

Well first of all you instead of using a transform variable, for your MyEnd script, just make 3 static float variable for x position, y position, and z position. So in in your checkpoint script say:

 MyEnd.xPos = transform.position.x;
 MyEnd.yPos = transform.position.y;
 MyEnd.zPos = transform.position.z;

instead of:

 col.GetComponent(MyEnd).checkpoint = transform;

and then in a new script say:

 // Import the System.IO Classes
 import System;
 import System.IO;
 // Set the file path variables
 static var filePath2 : String = "C:/ProgramData"; //a hidden folder in computers.
 static var fileName2 : String = "GameData";

 static function Save ()
 {
    // create vars
    var saveXPos : String = "" + MyEnd.xPos;
    var saveYPos: String = "" + MyEnd.yPos;
    var saveZPos : String = "" + MyEnd.zPos;


    // Open the file
    var saveStream : StreamWriter = new StreamWriter (filePath2 + "/" + fileName2 );
   
    // Write the save data
    saveStream.WriteLine(saveXPos);
    saveStream.WriteLine(saveYPos);
    saveStream.WriteLine(saveZPos);
 
   
   // Close the file
   saveStream.Close ();
   
   // Give confirmation that the file has been saved
   print ( "Data Saved at: " + filePath2 + "/" + fileName2 );

} so now in any script you can just say for example:

 SaveScript.Save();

to save your checkpoint progress and to load it make another script:

 import System;
 import System.IO;
 static var filePath : String = "C:/ProgramData";
 static var fileName : String = "GameData";

 function Load ()
 {
      //make vars
      saveXPos : String = "";
      saveYPos : String = "";
      saveZPos : String = "";
 
      //Opeb the file
      var saveStream : StreamReader = new StreamReader ( filePath + "/" + fileName );

      //read the save data
      saveXPos = saveStream.ReadLine();
      saveYPos = saveStream.ReadLine();
      saveZPos = saveStream.ReadLine();

      //turn the string into numbers
      var intX = float.Parse(saveXPos);
      var intY = float.Parse(saveYPos);
      var intZ = float.Parse(saveZPos);

      //now we have variables to use
      MyEnd.xPos = intX;
      MyEnd.yPos = intY;
      MyEnd.zPos = intZ;
 }

...phew, hope that helps! :)

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 john-essy · Aug 06, 2011 at 03:08 PM 0
Share

JEEEESE you are a legend mate ive been trying to figure this out for about a week now

avatar image Rydrako · Aug 06, 2011 at 03:18 PM 0
Share

I just looked up how to save player progress in unity for my own game. :)

avatar image
0

Answer by john-essy · Aug 06, 2011 at 03:22 PM

haha really cool mate

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

5 People are following this question.

avatar image avatar image avatar image avatar image avatar image

Related Questions

simple checkpoint/save/load system in javascript 4 Answers

checkpoint level please 2 Answers

Save and Load from XML help 1 Answer

Serializer.Resume() not working for multiple levels 0 Answers

Auto-save/Checkpoint system that you can load when restarting the game 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