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 markus2976 · Jun 22, 2013 at 04:59 PM · c#instantiateobject

C# create and destroy objects

Google Translated question :

I think I know where my problem is but do not implement it differently, I think I alive on the false in a created object do what it was destroyed, false is not assigned in update because it is also a function other times I think so outside of update is in another code block. The intention should be to create one object and create a new until it is destroyed.


Original Question :

c# objekt erstellen und zerstören

Ich denke ich weiß wo mein Problem ist weiß es aber nicht anders umzusetzen, ich denke da ich das alive auf false in einem erstellten Objekt mache was kurz darauf zerstört wird, wird false nicht in update zugewiesen weil es auch eine andere Funktion ist denk ich mal also außerhalb von update liegt in einem anderem Codeblock. Sinn der Sache sollte sein 1 Objekt zu erstellen und kein neues zu erstellen bis dieses zerstört ist.

 using UnityEngine;
 using System.Collections;
 
 public class instance : MonoBehaviour 
 {
 public GameObject obj;        // um ojekt zu instanciaten
 
 public bool alive;          // ist das objekt derzeit vorhanden
 
 public int howMuchBalls = 0;  //counter für wieviel erreicht
     
     
         
     // Update is called once per frame
     void Update () 
     {
         //testen ist nicht alive einmal kreieren und auf true setzen
         if (alive == false) 
         {
             GameObject myPrefab = (GameObject)Instantiate(obj);
             alive = true;
         }
                             
     }
         
     void OnCollisionEnter(Collision collision) 
     {
          // auf false setzen das ein neues Objekt bei update erstellt werden kann
          alive = false; 
         
         // wenn collusion mit player spiele audio ab unsichbar und zerstören
         if ( collision.gameObject.name == "Playerball" ) 
          {    
             audio.Play();    
             renderer.enabled = false;    
             Destroy(gameObject,1);
          }
 
 //        if ( collision.gameObject.name == "BodenFuerCollision" )
 //        {    
 //            alive = false;
 //            howMuchBalls ++;
 //            Debug.Log(howMuchBalls);
 //            Destroy(gameObject);
 //            
 //        }
             
     }
     
     
 }
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 AlucardJay · Jun 23, 2013 at 01:44 AM 0
Share

You probably have negative votes because the question is not written in English.

For the people negatively voting, try using Google Translate !

@markus2976 : please use a translator to post your question in both English and your own language after that, then you should not receive negative votes.

I have upvoted this question, but cannot remove all the negative votes (-2 at this post)


Sie haben wahrscheinlich negative Stimmen, weil die Frage nicht in englischer Sprache verfasst.

benutzen Sie bitte einen Übersetzer, um Ihre Frage in Englisch und Ihrer eigenen Sprache nach, dass zu senden, dann sollten Sie nicht empfangen negative Stimmen.

Ich habe diese Frage upvoted, kann aber nicht entfernen Sie alle negativen Stimmen (-2 in diesem Beitrag)

0 Replies

· Add your reply
  • Sort: 

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

16 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

Related Questions

Random array issue C# 2 Answers

overlapping object doesn't disable 1 Answer

How do I instantiate certain objects to appear in a specific spot? 3 Answers

Distribute terrain in zones 3 Answers

Randomly instantiate objects from array without choosing the same item twice. 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