• 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 /
This question was closed Feb 25, 2014 at 06:55 PM by unimechanic for the following reason:

The question is answered, right answer was accepted

avatar image
0
Question by Twitch1139 · Feb 23, 2014 at 02:34 PM · checkpoint

Checkpoint help

Ok i've tried quite alot of different scripts for checkpoints , few have worked a few havnt , but heres my thing , every script auto respawns my character , how can i make it so when i press backspace i can then go back to checkpoint , same if i die , i stay dead till i press backspace. I'm not the best at scripting , i can edit little bits, if anyone is feeling generous, please wright me a script for this, thank you :)

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 Linus · Feb 24, 2014 at 01:01 AM 0
Share

Converted this from answer to comment. The answer was not shown to me when I came from the moderation que, so I mistakenly posted it under question.

$$anonymous$$ake sure to use the comment function and not the answer when commenting.

2 Replies

  • Sort: 
avatar image
1
Best Answer

Answer by Nick4 · Feb 23, 2014 at 04:56 PM

Player script :

 public class PlayerScript : MonoBehaviour {
 
     Vector3 respawnPoint;
     bool dead;
 
     void Start()
     {
         respawnPoint = new Vector3(0,0,0); // STARTING POSITION
     }
 
     void Update () 
     {
         if(dead)
         {
             if(Input.GetKeyDown(KeyCode.Backspace))
             {
                 transform.position = respawnPoint;
             }
         }

         if(Input.GetKeyDown(KeyCode.Backspace))
         {
             transform.position = respawnPoint;
         }

     }
 
     void checkpointPos(Vector3 checkpoint)
     {
         respawnPoint = checkpoint;
     }
 }

Checkpoint Script :

 public class CheckPoint : MonoBehaviour
 {
     GameObject player;
 
     void Start()
     {
         player = GameObject.FindGameObjectWithTag("Player");
     }
 
     void OnTriggerEnter(Collider co)
     {
         if(co.gameObject.tag == "Player")
         {
             player.SendMessage("checkpointPos", transform.position);
         }
     }
 }

Note that checkpoint script should be attached to a cube object that is large enough to cover all the space in the area checkpoint and that cube must have a box collider with "is trigger" enabled. Add rigidbody, too. Finally, make sure to remove its mesh renderer so that player doesn't see it. Scripts could've been better but that's what you get for free :)

Comment
Add comment · Show 6 · 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 Twitch1139 · Feb 24, 2014 at 12:49 AM 0
Share

i keep getting this error

Assets/Scripts/PlayerCheckpoint.cs(1,29): error CS0246: The type or namespace name `$$anonymous$$onoBehaviour' could not be found. Are you missing a using directive or an assembly reference?

avatar image Twitch1139 · Feb 24, 2014 at 12:49 AM 0
Share

only on the checkpoint script though

avatar image Twitch1139 · Feb 24, 2014 at 01:14 AM 0
Share

actualy, i'm getting it on both

avatar image Nick4 · Feb 24, 2014 at 06:36 AM 0
Share

Don't forget that these are c# scripts, not javascript or boo.

avatar image Twitch1139 · Feb 24, 2014 at 11:47 AM 0
Share

ok i got it workin with no errors, but it teleports me into the ground rather than at the checkpoint , how do i set it to respawn me at the last checkpoint

Show more comments
avatar image
-1

Answer by unimechanic · Feb 25, 2014 at 06:54 PM

[Question answered, adding this to remove it from Unanswered list]

Comment
Add comment · 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 perchik · Feb 25, 2014 at 06:55 PM 0
Share

why do you do this? I don't understand what it accomplishes.

avatar image unimechanic ♦♦ · Feb 25, 2014 at 07:13 PM 0
Share

The message is clear. For some reason this question was marked with 0 answers, but it has 1, I added the answer to remove it from the Unanswered list. Did you down-vote this answer?

avatar image perchik · Feb 25, 2014 at 07:21 PM 0
Share

It's not a valid answer to the question.

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

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

Related Questions

Multiple Cars not working 1 Answer

The name 'Joystick' does not denote a valid type ('not found') 2 Answers

Player lives script help 1 Answer

Animation spins wildly after completed 0 Answers

hide object start script 4 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