• 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 Jan 02, 2016 at 08:54 PM by MadsWiering for the following reason:

The question is answered, right answer was accepted

avatar image
0
Question by MadsWiering · Jan 02, 2016 at 07:57 PM · gameobjectinstantiate

[Solved]GameObject Destroy

So in my scene I have an GameObject called "Enemy". It has an circlecollider with IsTrigger set Active. I use another object to instantiate clones of the "Enemy". And when it hit them they get destroyed.

So far so good, i got that working.

But the initial enemy is still coming at my mainplayer en when i hit it, it gets destroyed, which in result that i can't instantiate any more enemies.

My question is. Can i set the initial gameobject as inactive or something else. So i cannot destroy the initial gameobject so it can keep on going spawning clones of these.

Or is there another way i can keep the gameobject "enemy"in my hierarchy but not in my scene?

Comment
Add comment · Show 10
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 ShadyProductions · Jan 02, 2016 at 08:00 PM 0
Share

$$anonymous$$ake an empty gameobject, put the script on that? Also make sure you don't forget to correct any references if you decide to do so.

Show more comments
avatar image ShadyProductions · Jan 02, 2016 at 08:27 PM 0
Share

I'm pretty sure I'm correct. You must be doing it wrong. Just an empty gameobject with a script, nothing else on it. It can never get into any trigger cause there's nothing there.

avatar image vintar · Jan 02, 2016 at 08:31 PM 0
Share

You should use a basic object pool in your case.

Show more comments

2 Replies

  • Sort: 
avatar image
1
Best Answer

Answer by MadsWiering · Jan 02, 2016 at 08:52 PM

Already found the answer.

Make a prefab in your project folder. Name it something. and drag the gameobject to it. Delete the gameobject from the scene/hierarchy.

In the script where you Instantiate your gameobject. Make a public gameobject and drag to prefab into it.

Comment
Add comment · Show 2 · 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 ShadyProductions · Jan 02, 2016 at 08:54 PM 0
Share

oh lol you weren't instantiating a prefab? lmao

avatar image MadsWiering ShadyProductions · Jan 02, 2016 at 08:56 PM 0
Share

Wasn't aware that it existed :P ( pretty new to unity)

avatar image
0

Answer by Graphics_Dev · Jan 03, 2016 at 04:25 AM

The best way to do this would be to make and instantiate a prefab rather than duplicating an object already in your scene. Check out Unity's space shooter tutorial to see how do this:

http://unity3d.com/learn/tutorials/projects/space-shooter-tutorial

Let me know if this helps :)

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

Welcome to Unity Answers

If you’re new to Unity Answers, please check our User Guide to help you navigate through our website and refer to our FAQ for more information.

Before posting, make sure to check out our Knowledge Base for commonly asked Unity questions.

Check our Moderator Guidelines if you’re a new moderator and want to work together in an effort to improve Unity Answers and support our users.

Follow this Question

Answers Answers and Comments

41 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 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 avatar image

Related Questions

Spawn Prefabs 1 Answer

How to clone a simple GameObject where specified. 1 Answer

How to not instantiate an object if there is another object there? 1 Answer

Finding multiple objects by the same tag as to place them in one array? 2 Answers

Instantiated Prefab doesn't find main camera 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