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 kingsman142 · Aug 18, 2011 at 06:22 PM · instantiatedestroyyieldwaitforseconds

Destroy then Clone Help please?

I'm trying to write a script that Destroys an object after 3 seconds, then waits 2 more seconds, then clones that object so it can continue. The problem I'm having is the object never gets destroyed. Here's my code:

 //Sphere Countdown

 //Public Variables
 var wait : int = 5;

 //Private Variables


 function CoUpdate () 
 {
     Destroy(gameObject,3);
     yield WaitForSeconds(wait);
     Instantiate(gameObject);
 }

Also, is there any way I could call in another script when the object clones itself?

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 TheDarkVoid · Aug 18, 2011 at 06:41 PM 0
Share

it's impossible since the script is destroyed with the object so it never gets to the point of instantiate.

2 Replies

· Add your reply
  • Sort: 
avatar image
0

Answer by MobinS · Aug 18, 2011 at 06:57 PM

First hi Then Come On! :D the script will go on till " Destroy(gameObject,3); " then it will destroy the object that script is in it! so it wouldn't continue... you can do 3 way : 1.move the script to onother gameobject 1. move the script to another gameobject and then use " gameobject.find " to find the object that need to be destroyed & then destroy it 2. 3 or you can easily put destroy on the last line ... and if you want to disapear it just for a few sec and then destroy it use " gameobject.renderer == false " ....

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 kingsman142 · Aug 19, 2011 at 12:26 AM 0
Share

lol I felt so stupid once you pointed out that it will destroy that game object and the scripts

avatar image
0

Answer by Anxo · Aug 18, 2011 at 07:07 PM

On the object to be destoryed

 public var GameControl : GameObject;
 
 function GetRidOff()
 {
 GameControl.BroadcastMessage("SpawnNew");
 Destory(gameObject,3)
 
 }

On the GameControl Object

 function SpawnNew(){
 yield WaitForSeconds(5);
 Debug.Log("Instantiating");
 }
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

5 People are following this question.

avatar image avatar image avatar image avatar image avatar image

Related Questions

Yeild and WaitForSeconds and Instantiate 1 Answer

Instantiate an object as soon as another object is destroyed 2 Answers

Respawn after delay 3 Answers

Respawn after delay 3 Answers

instatiate gameobject after 1 second 1 Answer


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