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 Evan Stallings · Aug 15, 2013 at 02:56 AM · c#destroysprites

Destroying Custom Planes

Hi. I just learned about CustomPlanes and am using them for sprites (so that I can properly and easily make billboards) but am now having trouble destroying them. I am using these planes as I said, for sprites which are my enemies. I have a bullet script on my bullets but it does not destroy these planes. Here is the script:

 using UnityEngine;
 using System.Collections;
 
 public class BulletScript : MonoBehaviour 
 {
     float lifespan = 3.0f;
     
     void Update () 
     {    
         lifespan -= Time.deltaTime;
         if (lifespan <= 0) 
         {
             Explode ();
         }
     }
     
     void OnCollisionEnter(Collision collision) 
     {    
         if (collision.gameObject.tag == "Enemy") 
         {
             Destroy (gameObject);        
         }
     }
     
     void Explode () 
     {    
         Destroy (gameObject);
     }
 }

Any help would be greatly appreciated. Thanks!

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

Answer by robertbu · Aug 15, 2013 at 03:06 AM

The Wiki CreatePlane script produces the mesh, but unlike the built-in planes, it does not add a collider. Depending on the needs of your game, you need to add either a mesh collider or a box collider to the planes. Select the plane in the hierarchy and use either Component>Physics>Box Collider or Component>Physics>Mesh Collider.

Comment
Add comment · Show 5 · 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 Evan Stallings · Aug 15, 2013 at 03:09 AM 0
Share

Did that already, should have said (sorry) did not work. (tried both mesh and box....)

avatar image robertbu · Aug 15, 2013 at 03:32 AM 0
Share

Do you bullets hit the collider (i.e. do the bounce off)? Is it a speed problem...if you slow them down, do then then collide? Are you sure you have not set the IsTrigger flag on the colliders? Note either the bullet or the plane needs to have a rigidbody for a collision.

avatar image Evan Stallings · Aug 15, 2013 at 03:38 AM 0
Share

They do not hit - go right through even at incredibly low speeds... yes I am sure about the Trigger, and the bullet prefab has a rigidbody.

...Hmmm... I have no idea what the problem is.

avatar image robertbu · Aug 15, 2013 at 04:13 AM 0
Share

Planes are one sided. Are you hitting the front? You may be using a shader that displays both sides. $$anonymous$$ake sure you try a box collider, since it will register a hit from either side. Turn on Gizmos and verify the collider size and position in Scene view.

avatar image Evan Stallings · Aug 15, 2013 at 01:05 PM 0
Share

I just put a script on the enemy that says if it is hit by a bullet then it gets destroyed. Thanks though and I will still do this but this works for now.

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

15 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

Related Questions

Destroy a gameobject from a script on a different game object by tag? 1 Answer

Trigger...Spawn...Destroy 1 Answer

Check if object is destroyed on level load, if so instantiate prefab? 1 Answer

how to instantiate object with content prefab and not him self 2 Answers

Destroying object when player walks over it 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