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 Mattwj10 · May 20, 2015 at 07:22 AM · c#respawnvoidrespawning

How to get your player to respawn when in void (C#)

Hello

I am creating my first game and i am struggling on how to get my sphere that rolls off the edge of my cube to respawn when it is falling in the void.I would like to know how to respwan using the letter R to respawn my player back at the start of the level.

Thanks -Matthew

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

2 Replies

· Add your reply
  • Sort: 
avatar image
2

Answer by $$anonymous$$ · May 20, 2015 at 07:23 AM

This script should be attached to your Sphere

 private void Update()
     {
         if (Input.GetKeyDown(KeyCode.R))
             this.transform.position = RespawnPos; // RespawnPos is Vector3
 
         if (transform.position.y <= SPECIFIC_FALL_HEIGHT) // If CUrrent Y position is lower than SPECIFIC_FALL_HEIGHT, don't let it fall further
             this.transform.position = RespawnPos;
     }
Comment
Add comment · 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 Mattwj10 · May 20, 2015 at 07:40 PM 0
Share

Thanks :)

avatar image Mattwj10 · Jun 09, 2015 at 06:26 PM 0
Share

it does not seem to be working how do i set a specific fall height

avatar image
1

Answer by Gardes · Jun 09, 2015 at 07:20 PM

Add this to your player

     Vector3 respawn_Pos;
 
     void Start () {
         respawn_Pos = transform.position;
     }
 
     void Update () {
         if (Input.GetKeyDown(KeyCode.R))
             transform.position = respawn_Pos;
     }
Comment
Add comment · 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 Mattwj10 · Jun 11, 2015 at 10:16 AM 0
Share

cheers I have got it working! :)

avatar image Gardes · Jun 11, 2015 at 01:48 PM 0
Share

I'm glad you got it ;) $$anonymous$$ark this as the answer then :)

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

3 People are following this question.

avatar image avatar image avatar image

Related Questions

How to refer to run a "void" in one c# script from another to respawn a player 0 Answers

Multiple Cars not working 1 Answer

Distribute terrain in zones 3 Answers

Why can't I make my character die? 3 Answers

Player won't respawn after timer hits zero. 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