• 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
Question by Apexuni · May 24, 2010 at 06:31 AM · checkpoint

checkpoint question????

how can i make chekpoint system in unity. like when player touch 1st check point collider then die so he re spawn at 1st check point position if the the player touch 2nd check point & then die so, he re spawn at 2nd check point position

so, basically how to store these information in the script

thanks in advance

Comment
zyad137
unknownsk

People who like this

2 Show 0
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

5 Replies

· Add your reply
  • Sort: 
avatar image

Answer by David O'Donoghue · May 24, 2010 at 07:33 AM

On your player add a public variable

public Collider currentCheckPoint;

Then create empty game objects with a box collider set to "Trigger" and create a script like this, make sure you replace "PlayerScript" with the name of your player's main control script and "Playerobject" with the name of your players gameobject.

void OnTriggerEnter() {

PlayerScript myPlayer = (PlayerScript) GameObject.Find("Playerobject").GetComponent("PlayerScript");

myPlayer.currentCheckPoint = this;

}

Now you can find out where the check point is when he dies and move the player.

Inside the player's script you can have a function like this:

void PlayerDied() {

this.transform.position = currentCheckPoint.position;

}

Comment
_Petroz
Lawrie
FlintCLeaver
EnriqueL

People who like this

4 Show 3 · 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 Apexuni · May 24, 2010 at 07:40 AM 0
Share

hey thanks david but the problem is i am using java script how can i convert this script in java

avatar image spycarrot · Jul 24, 2015 at 07:40 PM 0
Share

Hey Apexuni, your going to need to learn how to translate between these two computer languages to get the most out of this forum. Also, Javascript and Java are two entirely different languages.

avatar image zyad137 · Sep 21, 2015 at 07:55 AM 0
Share

i have a problem in your script david it tell me this error i need help please

Assets/checkpoint.cs(3,7): error CS0246: The type or namespace name `Path' could not be found. Are you missing a using directive or an assembly reference?

avatar image

Answer by spinaljack · May 24, 2010 at 09:55 AM

http://unity3d.com/support/resources/tutorials/3d-platform-game

This tutorial has exactly what you need, a set of check points that are activated and deactivated as you walk over them. Just read the tutorial and lift the code from the resources.

Comment
_Petroz
Tetrad

People who like this

2 Show 0 · 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

Answer by GameRocker · Jan 25, 2013 at 05:31 PM

A Video Is Made By Me On Same Topic! Link Of Video Is http://youtu.be/blzoX2guK2s

You Should Also Search For Saving Scene By Script This Might Also Help You! I Am Working On It.

Comment
Loius

People who like this

-1 Show 4 · 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 Loius · Jan 25, 2013 at 06:11 PM 1
Share

This is extremely unhelpful, and it's clearly not an answer, and this is an incredibly old topic, and you double-posted.

avatar image GameRocker · Jan 26, 2013 at 02:22 PM 0
Share

Sorry But The Others Who Came Here For Help May Find This Useful.

avatar image JoeDerpz · Nov 04, 2013 at 08:23 PM 0
Share

@gameRocker your videos in such low quality nobody can read your code and you should always post your code in the info of the video just in case..

avatar image leonardozimbres · Nov 13, 2014 at 10:58 AM 0
Share

saving scene by script? I will take a look at it.

avatar image

Answer by dre38w · Nov 09, 2010 at 04:48 PM

Javascript? Try this.

private var originalSpawn : boolean = true; private var respawn2 : boolean; private var respawn1 : boolean;

function OnTriggerEnter(other : Collider) { //You'll have to make a death script and make a boolean true false command. if (dead == true) { if (originalSpawn == true) { //Put your coordinates of the original spawn point. transform.position = Vector3(x, y, z); } }

if (other.gameObject.tag == "Checkpoint1") { originalSpawn = false; respawn1 = true; respawn2 = false; }

if (respawn1 == true) { if (dead == true) { //Put your coordinates of the spawn point. transform.position = Vector3(x, y, z); } }

if (other.gameObject.tag == "Checkpoint2") { originalSpawn = false; respawn2 = true; respawn1 = false; }

if (respawn2 == true) { if (dead == true) { //Put your coordinates of the spawn point. transform.position = Vector3(x, y, z); } } }

Hopefully this works.

Comment

People who like this

0 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 LearningWhileScrewing · Jun 15, 2016 at 10:47 AM 0
Share

guys remember to add #pragma strict

avatar image LearningWhileScrewing · Jun 15, 2016 at 11:04 AM 0
Share

and did there have to told what dead is like: var dead : Transform; or something without and explain for the unity it is marked as a error

avatar image

Answer by santiandrade · Nov 19, 2015 at 12:29 PM

I explain how to create a checkpints system in my blog: https://santiandrade.github.io/Unity-Creating-a-checkpoints-system/

Good luck!

Comment

People who like this

0 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 LearningWhileScrewing · Jun 15, 2016 at 10:48 AM 0
Share

That's C Sharp who likes it?? Java script is what i'm here for -.-''

avatar image coltrain12000 · May 21, 2017 at 09:46 PM 0
Share

thanks im using c# and this was a big help however there seems to be an issue with GetComponent in the newer versions please let me know of any fixes

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.

Welcome to Unity Answers

If you’re new to Unity Answers, please check our User Guide to help you navigate through our website and refer to our FAQ for more information.

Before posting, make sure to check out our Knowledge Base for commonly asked Unity questions.

Check our Moderator Guidelines if you’re a new moderator and want to work together in an effort to improve Unity Answers and support our users.

Follow this Question

Answers Answers and Comments

6 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Checkpoints? 0 Answers

how to make a checkpoints on unity for one player 1 Answer

If Dead,Checkpoint and reset 2 Answers

Restarting game from last checkpoint. 1 Answer

Teleporting 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