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 avalon45 · Aug 09, 2012 at 05:47 AM · javascriptsaveloadsystemcheckpoint

simple checkpoint/save/load system in javascript

In my game I would like to setup a system where if the player dies it will take them back to the position they were before they died and the walls rotated in the position they were before death since the premise of the game is to rotate walls to get from point a to b. For the save and load system I wanted to make it so the player can save at the end of a stage and load the beginning of a level if they leave/quit the game. I'm working in javascript. If anyone could help with that it would be apperciated.

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

4 Replies

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

Answer by fafase · Aug 09, 2012 at 07:18 AM

http://answers.unity3d.com/questions/8480/how-to-scrip-a-saveload-game-option.html

or

http://docs.unity3d.com/Documentation/ScriptReference/PlayerPrefs.html

for saving game.

Now for the respawn of the player. Place some trigger boxes around the level where you want to checkpoint add this.

On the player add a variable:

 var checkpointPosition:Vector3;

On the trigger boxes

 var player:PlayerScript;
 function Start(){
   player = GameObject.Find("Player").GetComponent(PlayerScript);} 
 function OnTriggerEnter(other:Collider){ 
   if(other.gameObject.tag=="Player"){ 
     player.checkpointPosition = transform.position;} 
 } 

When the player enters the box, the box position is assigned to the variable.

Now back on the player:

 function Start(){
   checkpointPosition=Vector3(0,0,0);} 
 function Update(){
   if(health<=0)transform.position = checkpointPosition;
 }

I assume your player start at 0,0,0 but obviously you know what to do. If your player reaches 0 for health, he is sent to checkpointPosition.

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 avalon45 · Aug 09, 2012 at 03:54 PM 0
Share

Thanks alot

avatar image
0

Answer by medi88 · Apr 25, 2013 at 12:49 AM

pleez i want to ask . i have the same problem as u and i wante to use Application.LoadLevel(); when the player die . and respown in the position of last chek points ( use application.loadlevel to make my enemys disappertre) can i use it with the chek points??

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
avatar image
0

Answer by morinzm · Jul 05, 2014 at 03:20 PM

So what you would want to do @medi88 is to have a collision with a model of sorts and then do search for a tagged object with the tag player and then have it application.loadlevel as the result.

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
avatar image
0

Answer by cmc4543 · Aug 15, 2014 at 07:57 PM

@medi - DontDestroyOnLoad

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

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

Saving lots of objects (Only answer in JavaScript) 1 Answer

Trying to save/load game, codes doesnt do anything. not even an error. 1 Answer

Scene Saving 1 Answer

checkpoint level please 2 Answers

half life save/load system ? 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