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 PeeG · Sep 20, 2012 at 10:53 AM · transformdestroycomponentclone

Destroying a Transform Component

I am new to Unity and am using a code developed by someone else initially made over two years ago. He had the code destroying a transform component, which previously worked, but now the version 3.4.2 I am using does not allow this transform to be destroyed. Has this changed in a later version?

Further to this I have one gameobject (a fire event) which has many transforms created from it. As I change the position of a wall it collides with I want to destroy the old transform (or clone) and recreate a new one with the correct conditions. Can I destroy this clone / transform in the script as can be done in the inspector by a right click and delete? Or can I hide it in the background or even adapt the transform to the new conditions?

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
4
Best Answer

Answer by Sisso · Sep 20, 2012 at 11:20 AM

A GameObject has many Components, one of them is Transformation. So, if you want to destroy something, aways destroy its GameObject.

 // my transform reference
 var trans : Transform = ...
 
 // I must pass it's gameObject to destroy my "transformation"
 Destroy(trans.gameObject)

About your another question. Yes, you could destroy theses "clones", but first you must know how to access. Take a look on these links:

GameObject has static methods that you can search for Objects:

http://docs.unity3d.com/Documentation/ScriptReference/GameObject.html

Transform has methods to navigate between parents and children:

http://docs.unity3d.com/Documentation/ScriptReference/Transform.html

More reference: http://docs.unity3d.com/Documentation/ScriptReference/index.html

Comment
Add comment · Show 6 · 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 PeeG · Sep 20, 2012 at 11:25 AM 0
Share

Thanks for your reply.

Has this changed with deleting a transform by itself and not having to delete the game object? I ask that as this code worked previously. I will check out those links.

avatar image Sisso · Sep 20, 2012 at 11:41 AM 0
Share

I am not a old unity user, so I didn't know if it works before.

You can use Destroy to remove GameObject components. But I think that they remove to force every GameObject have always a transformation.

http://docs.unity3d.com/Documentation/ScriptReference/Object.Destroy.html?from=GameObject

avatar image PeeG · Sep 20, 2012 at 11:52 AM 0
Share

Cheers. I have tried the Destroy(trans.gameObject) which destroys all transforms and the game object which then won't allow me to instantiate any future transforms I need. So I just need to destroy or change the transform by itself, but leave the game object with the code in its current form.

avatar image Shrandis · Sep 20, 2012 at 12:09 PM 0
Share

You cannot destroy the transform component of a game object.

avatar image PeeG · Sep 20, 2012 at 03:04 PM 0
Share

All sorted. Your answer helped me identify the issues. Some of what had been identified as transforms should have been game objects. This then required destroying a clone as well. Thanks for your help.

Show more comments

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

11 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

Related Questions

Destroy Child of Game Object 2 Answers

How do I duplicate an object to work with a shootemup 0 Answers

How to destroy more than one clone at runtime??? 1 Answer

Component Disabling vs. Destroying 1 Answer

NullReferenceException on TransformArray 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