Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 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 larrielyn · Sep 10, 2011 at 04:10 AM · destroytime

how to add time ? (how to show a guiTexture and hide it after some time?)

good day !! ..help please .. how to add time when the character destroy the object ..

function OnTriggerEnter (other : Collider) {
  Destroy(gameObject);
  gameObject.Find("balisong").GetComponent("GUITexture").enabled = true;
} 
-this is my code when i destroy the object. Where i place the code of adding time . and how? thank you so much

COMMENTS POSTED AS ANSWERS AND MOVED HERE/DELETED (by aldonaletto):

1- thankyou ! i'll try it :)
2- how to disapper the guitexture after seconds. ? not the gameobject ..
3- how to disappear the GUITexture when the gameobject destroy? for example .. when the character destroy the object the guitexture will appear but after 5 seconds the guitexture will disappear .. thx ..!

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 aldonaletto · Sep 10, 2011 at 01:37 PM 0
Share

@larrielyn, I edited my answer to show how to get the expected result. I also edited the question and added the comments/replies you've posted as answers, and deleted that answers. UA works is not like forums: the answer box should be used only to answer your question, while comments, replies etc should be posted with the button add new comment (I know, nobody told you that before...)

avatar image puzzledragon · Sep 11, 2011 at 03:16 PM 0
Share

try the scripting reference it has a time section

1 Reply

· Add your reply
  • Sort: 
avatar image
2

Answer by aldonaletto · Sep 10, 2011 at 04:15 AM

Add time to what? If you want to delay the object destruction, you can use something like this:

 Destroy(gameObject, 5); // destroy after 5 seconds

EDITED: Ok, so you want to enable the GUITexture and disable it after some delay. The best alternative is to create a function in the "balisong" object, and modify the script below to call it. Let's suppose the script attached to balisong is called BalisongScript.js (change the GetComponent argument if the script has a different name):

function OnTriggerEnter (other : Collider) {
  Destroy(gameObject);
  // call the function Show in the BalisongScript.js
  GameObject.Find("balisong").GetComponent(BalisongScript).Show();
} 
In the balisong object, add the code below to its script - or create a new script, if it has none:

function Show() {
  guiTexture.enabled = true; // enable the guitexture
  yield WaitForSeconds(5);   // 5 seconds delay
  guiTexture.enabled = false; // disable guiTexture
} 

NOTE: The Your Answer box must be used only to post answers to your question - use the minuscule add new comment button in the question or answers to post replies or comments.

Comment
Add comment · Show 4 · 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 larrielyn · Sep 10, 2011 at 06:48 PM 0
Share

sorry for being naughty ..I did, what you told but this line says that cannot be assigned to. i create BalisongScript.js then attach it in GUItexture but does not work . sorry again :(

GameObject.Find("balisong").GetComponent(BalisongScript).Show() = true; }

avatar image aldonaletto · Sep 10, 2011 at 07:22 PM 0
Share

I tested the scripts above, and they worked fine. Let's check if the sequence is ok:
1- I attached the first script to the trigger object;
2- I created a GUITexture and named it "balisong";
3- I attached the BalisongScript.js to the balisong object;
Did you do the same? If you got any error, post it here.
NOTE: I've just found an error in the trigger script above: I forgot "= true" after "GetComponent(...).Show()" when I edited the answer. Now I fixed the answer, and it should work as in my tests.

avatar image larrielyn · Sep 11, 2011 at 02:57 AM 0
Share

suppose to be this .. right?

GameObject.Find("balisong")=true.GetComponent(BalisongScript).Show();

}

i found the error again says "cannot be assigned to"

avatar image aldonaletto · Sep 11, 2011 at 06:51 AM 0
Share

No, there's no '=true' in this line - I didn't make myself clear, I suppose. You can copy the script from my answer now - I already fixed it.

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

5 People are following this question.

avatar image avatar image avatar image avatar image avatar image

Related Questions

using Contains(gameObject) to find and destroy a gameObject from a list 2 Answers

How to add a seconds when you destroy the object ? 1 Answer

Destroy instances after set time 1 Answer

How to destroy in an amount of time 1 Answer

Rocket to disappear after a few 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