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 /
This question was closed May 07, 2018 at 08:15 AM by Myth for the following reason:

The question is answered, right answer was accepted

avatar image
0
Question by Myth · Feb 03, 2011 at 02:56 AM · gameobjectmeshdestroyrendererissue

Can't remove component. MeshRenderer depends on it

What can I do about this error?

Currently I have an object that should die (Destroy currently) when health <= 0 and instead I get this error

here is the code that should rid me of the object:

// vars var health : float = 100; var armour : float = 0; var shield : float = 0;

// supporting vars var damage_hull : float = 0; var damage_shield : float = 0; var temp : float = 0;

// control vars var replace : boolean = false;

// objects var explosion : Transform; var replacement : Transform; var origional : Transform;

function Update () { if (health > 0.0 && shield <= 0.0) { if (armour > 0) { armour = armour - ( damage_hull / 2 ); temp = damage_hull - armour; if (temp > 0) { damage_hull = temp; } }

     health = health - damage_hull;
 }

 if (health &lt;= 0.0)
 {
     if (replace == false)
     {
         //Instantiate(explosion,transform.position, transform.rotation);
         Destroy (origional);
     }
     else
     {
         Instantiate(replacement,transform.position, transform.rotation);
         Destroy (origional);
     }
 }

}

function Hull_Damage_receiver (hull : float) { damage_hull = hull; }

function Shield_Damage_receiver (shield : float) { damage_shield = shield; }

Comment
Add comment · Show 3
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 DaveA · Feb 03, 2011 at 03:53 AM 0
Share

How are replacement and origional getting set?

avatar image Myth · Feb 03, 2011 at 04:17 AM 0
Share

Drag and drop into the inspector - I think?

avatar image Myth · Feb 03, 2011 at 04:18 AM 0
Share

Why? Does it make a difference in Unity? - I'm fairly new to it.

1 Reply

  • Sort: 
avatar image
2
Best Answer

Answer by Molix · Feb 03, 2011 at 03:53 AM

Since "origional" is a Transform, I think you probably want:

Destroy( origional.gameObject );
Comment
Add comment · Show 3 · 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 Myth · Feb 03, 2011 at 04:17 AM 0
Share

Thanks a lot - still can't get my head around it though!

avatar image Molix · Feb 03, 2011 at 05:17 AM 1
Share

If you Destroy the Transform (a Component), it is like trying to remove the Transform component from the GameObject. However, all Components expect there to be a Transform in their GameObject, so it complains.

avatar image Myth · Feb 03, 2011 at 06:07 AM 0
Share

Thanks for that.

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

Game object with animations 0 Answers

Animation : Mesh Renderer - Issue 0 Answers

Can't render GameObject 3 Answers

Turning off renderer in other game object (C#) 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