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 MC HALO · Nov 02, 2010 at 03:11 AM · gameobjectprefabdestroyrandom

How can i destroy a game object?

Hey Guys i just want to ask something, how can i destroy a game object but when it is destroyed it still has its scripts attached to it. Basically i am doing this because in my game the player can change is player by clicking on a character. is there anyway i can do that. or the second thing i was thinking is instead of destroying the object i was thinking once the new player re-spawns on the current player the first players mesh and script get turned of and then that activates the other player scripts. Please help me out thank you in advance.

Comment
Add comment
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

1 Reply

· Add your reply
  • Sort: 
avatar image
1
Best Answer

Answer by Tobbe Olsson · Nov 02, 2010 at 04:38 AM

Make a prefab, destroy it when you want and instantiate it when you want? A prefab can contain a hierarchy and scripts.

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 sriram90 · Nov 02, 2010 at 01:27 PM 0
Share

ya correct ans from Tobbe Olsson, just create a prefab and make instantiate for that, and just destroy that instantiate(clone) or prefab watever you want.

avatar image MC HALO · Nov 03, 2010 at 12:01 AM 0
Share

I have done this but my prefab starts to make clones how can i stop this

avatar image Tobbe Olsson · Nov 04, 2010 at 05:29 PM 1
Share

It seems maybe you need to explain a bit more what you are doing, maybe show the code. A prefab is just an empty container that you can contain everything you want (scripts, geometry, hierarchy, animations). So if your prefab starts making clones it's because you have a script attach to the prefab (and active in the scene) that tells it to create clones. Though I would also read up on the basics of prefabs and what you can do with them.

There are soo many great free Unity tutorials out there that walk you through it and explains the code. That's how I got started!

avatar image MC HALO · Nov 05, 2010 at 03:35 AM 0
Share

Thank you i have fixed the problem thanks to you i just noticed that all the scripts that i was adding where on the prefab after changing them everything is now O$$anonymous$$ thank you very $$anonymous$$UCH :)

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

No one has followed this question yet.

Related Questions

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

How to Play 3D Sound and Keep Script on Multiple Prefabs after Destroying a gameObject? 0 Answers

Trouble with destroying an instantiated prefab 2 Answers

Create a prefab at same position where its destroyed 3 Answers

Check if object is destroyed on level load, if so instantiate prefab? 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