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 FenuvaGames · Oct 30, 2012 at 09:13 PM · playerrespawnteleportfalling

Falling off respawn script

Greetings, I am currently creating a game where you have to jump from one cube to another and not fall off. I was walt textondering if there was any way that I could make it so the player respawns at the original spawn point after falling a little distance. Does anyone have scripts for my request? I am having a very hard time with this as I am quite new to Unity. May you explain in detail exactly what I do to have the player respawn on the original spawn point after falling off? I already created a invisible large rectangle under the map so the player falls off and lands on it. Now what do I do after this? How do I make it so the player teleport to the spawn point after hitting the invisible platform? I have set up something so that if the player falls off, it restarts the scene, but I don't like it. I want it so that my other scripts (Such as a timer or lives) do not restart when the player falls off. alt text

image.png (312.1 kB)
Comment
Add comment · Show 2
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 FenuvaGames · Oct 30, 2012 at 08:49 PM 0
Share

Sorry about accidently posting the same image twice.

avatar image deltamish · Oct 31, 2012 at 02:17 AM 0
Share

I have given answer to your question in http://answers.unity3d.com/questions/339115/falling-off-respawn.html

Create player a prefab(Drag the Player(with scripts and all) from the hirarchy to the project panel) Assign the player prefab to the player in my script;

1 Reply

· Add your reply
  • Sort: 
avatar image
1

Answer by speedything · Oct 30, 2012 at 10:50 PM

You need to keep track of the last block your person is on. Then, when he hits the invisible plane, you change his position to where he was at that time.

Do something like...

(on player GameObject)

 public Vector3 lastGoodPosition;
 
 void OnCollisionEnter(Collision collision)
 {
    if (collision.tag == "Block")
    {
       lastGoodPosition = transform.position;
    }
    else if (collision.tag = "PlaneOfDeath")
    {
    transform.position = lastGoodPosition;
    }
 }

You may need to tidy this up a little bit. For example, if the player hits a block as they're falling they'll end up in a cycle of death. However, this should get you started on the right path.

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 Zarack · Dec 29, 2012 at 08:00 PM 0
Share

I can't edit this code, but it'd actually be (collision.collider.tag == ... ) and the else if condition is missing a '='.

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

13 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

Related Questions

Falling off respawn 4 Answers

Finding the player that walked into a ray? 1 Answer

Respawn after falling off script? 2 Answers

Help - Player Respawn Help 2 Answers

2D Movement Problems 2 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