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 remvan3d · Jul 27, 2010 at 12:36 PM · delayrespawnonceonly

How to make my espawn delay trigger to work more than once.

I put this question up on the unity forum, but got so many different answers that I didn't know what to do. Tried out all of them but none seemed to work like I wanted. Some of them even did so that the script did not work. So I therefor they here since I have had more luck here before.

I have this respawn script that is supposed to delay the player repawn action by 5 seconds after passing -3 in the Y-axis. It is a diving game and so the point is to let the 5 seconds to show the score and so on before respawning back on the diving board. My problem is that the 5 second delay only works once. After the second jump of the board and the player hits -3 in the y-axis the player respawnes emediatly. I therefore need to make the script work everytime. I need the respawn action to be delayed everytime and not just once. Can someone help me please?

I have only been working with scripts for about a month now and I am still pretty wet behind the ears when it comes to unity script.

This is my code atm:

var reSpawnPoint: Transform; var timer : float = 0.0;

function Update ()

{ if(gameObject.transform.position.y < -3){ timer += Time.deltaTime; if(timer>5) gameObject.transform.position = reSpawnPoint.position;

} }

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 sovalopivia · Jul 27, 2010 at 01:28 PM 0
Share

In case that is how your code is formatted within your editor, and not just how you typed it up here; I would recommend utilising indenting and brackets for all if statements, it is easier to read.

See how $$anonymous$$ike did it below. :)

2 Replies

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

Answer by Mike 3 · Jul 27, 2010 at 12:45 PM

Just need to reset the timer variable to 0:

var reSpawnPoint: Transform; var timer : float = 0.0;

function Update () { if(gameObject.transform.position.y < -3) { timer += Time.deltaTime; if(timer>5) { timer = 0; gameObject.transform.position = reSpawnPoint.position; } } }

Comment
Add comment · 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
0

Answer by remvan3d · Jul 28, 2010 at 10:21 AM

Thanks a bunch!

Comment
Add comment · 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

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

No one has followed this question yet.

Related Questions

Make Arms Move Slow 0 Answers

Reset GUI texture after respawn 1 Answer

die then respawn after couple of secs when touching a ridgid body? 1 Answer

Finding the player that walked into a ray? 1 Answer

Sniper zooming (toggle) 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