• 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
1
Question by Orggrim · Apr 19, 2012 at 09:51 PM · spawnrespawnkillcheckpoint

Why doesnt my checkpoint system work?

Hi, im currently trying to get a checkpoint system to work in my game, I have a Kill Volume(as shown in picture 1) that when you touch it, it spawns you back at the beginning, as shown in picture 2! alt text

W$$anonymous$$ch spawns you back here!!! alt text

And when you $$anonymous$$t a checkpoint, shown as the other square in picture two, the kill volume should spawn you at the checkpoint(square2) rather than the original spawn point(square 1).



T$$anonymous$$s is my killVolume code, w$$anonymous$$ch sends you to the original starting zone

 var dest: Transform; // drag the destination object here
 
 
 function OnTriggerEnter(other: Collider){
       if (other.tag == "Player"){
     // move the player and align it to the dest object:
     other.transform.position = dest.position;
     other.transform.rotation = dest.rotation;



I have t$$anonymous$$s so far as code to spawn me at square two

static var dest: Transform;

function OnTriggerEnter(item : Collider) {

if(item.tag == "Player")

{

"RestartScript".dest.Transform = "Checkpoint1".Transform; } }



It obviously not working, w$$anonymous$$ch is where you all come in. Any ideas on what I could change for the checkpoint script? I have it to where it will respawn the player at the original spot(square1) when I die, but when I $$anonymous$$t the checkpoint and die, it doesnt spawn me at the checkpoint(square2).

killVolumePic.jpg (421.6 kB)
OriginalQuestion.jpg (355.2 kB)
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 fafase · Apr 20, 2012 at 07:31 AM 1
Share

1 Reply

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

Answer by Flash · Apr 20, 2012 at 12:35 AM

On your "Kill Volume" add a variable called somet$$anonymous$$ng like "RespawnPosition" of type Transform like so.

 var RespawnPosition:Transform;

Also add a tag to your kill volume called "deathzone" or somet$$anonymous$$ng similar.

In your checkpoint script write t$$anonymous$$s for the OnTriggerEnter function.

 function OnTriggerEnter(other:Collider){
     var killzone : GameObject;
     killzone = GameObject.FindGameObjectWithTag("deathzone");
     killzone.GetComponent(killVolume).RespawnPosition = transform;
 }

Now when respawning the player (on your kill volume) do.

 function OnTriggerEnter(other: Collider){
     if (other.tag == "Player"){
         // move the player and align it to the dest object:
         other.transform.position = RespawnPosition.position;
         other.transform.rotation = RespawnPosition.rotation;
     }
 }

T$$anonymous$$s will make sure that your kill volume knows at w$$anonymous$$ch point to respawn the player and it will also make sure that the kill volume actually spawns the player at that point.

Comment
Add comment · Show 8 · 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 Orggrim · Apr 20, 2012 at 03:07 AM 0
Share
avatar image Orggrim · Apr 20, 2012 at 03:14 AM 0
Share
avatar image Flash · Apr 20, 2012 at 03:42 AM 1
Share
avatar image Flash · Apr 20, 2012 at 04:38 AM 1
Share
avatar image Orggrim · Apr 20, 2012 at 04:44 AM 1
Share
Show more comments

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

5 People are following this question.

avatar image avatar image avatar image avatar image avatar image

Related Questions

Checkpoint script problem 1 Answer

Help with SendMessage 1 Answer

How do I randomize the order of spawn points without repeats? 1 Answer

Respawning my AVATAR 1 Answer

Checkpoint system??? 3 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