Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 14 Next capture
2021 2022 2023
2 captures
13 Jun 22 - 14 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 /
This question was closed Nov 20, 2021 at 06:53 PM by Bmarlyman21 for the following reason:

The question is answered, right answer was accepted

avatar image
0
Question by Bmarlyman21 · Jan 07, 2014 at 12:34 PM · yield waitforsecondsappeardissapear

Object Apear WaitForSeconds Disappear

what's wrong with this script? i'm trying to make it appear when i click the mouse and disappear after 1 second, but the yield WaitForSeconds doesn't work.

 function Start ()
 {
    renderer.enabled = false
 }
 
 function Update ()
 {
    if ( Input.GetMouseButtonDown(0) )
     {
         renderer.enabled = true;
         yield WaitForSeconds (1);
         renderer.enabled = false;
     }
 }

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 AlucardJay · Jan 07, 2014 at 12:40 PM 0
Share

For any help, please format your code. You can do this by highlighting all your code, then clicking the 10101 button at the top of the edit window.

  • Read this page : http://answers.unity3d.com/page/newuser.html

  • Watch : http://video.unity3d.com/video/7720450/tutorials-using-unity-answers


Update runs every frame, you cannot use Update as a coroutine. I'm surprised you don't have an error in the console saying so.

avatar image Bmarlyman21 · Sep 30, 2014 at 03:53 PM 0
Share

looking back at this now, I just feel stupid. I can't even believe how bad I was back then.

1 Reply

  • Sort: 
avatar image
1
Best Answer

Answer by NikoBusiness · Jan 07, 2014 at 01:26 PM

you have to put the WaitForSeconds method in a ienumerator so its like this in c#

  IEnumerator Example() {
         print("start");
         yield return new WaitForSeconds(5);
         print("end"); //this will apear after 5 seconds
     }

and then u call it in start or update function like this

 StartCoroutine("Coroutine Name");


and in javascript u just add yield WaitForSeconds in a function like this

  function Example () {
         print ("stard");
         yield WaitForSeconds (5);
         print ("end");
     }



dont forget to call the function so it works

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

Follow this Question

Answers Answers and Comments

20 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

Related Questions

how to make an enemy appear then disappear. (if possible with audio) 1 Answer

touch appear let go dissapear? 2 Answers

Materialize an object, then destroy it. 1 Answer

Making an object blinking for some time, then dissapearing 2 Answers

Appear after set number of seconds 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