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 Dec 04, 2014 at 05:00 AM by Prasanna for the following reason:

The question is answered, right answer was accepted

avatar image
0
Question by Prasanna · Jun 23, 2014 at 06:57 AM · destroyparticleemitteronparticlecollision

Particle Collision Problem

Hello there, I have created game with default particle collision. I used Explosion Particle, i need to destroy objects with that explosion, so i created OnParticleCollision with using tag name. but i miss something, someone please explain what i missed.

 public void OnParticleCollision(GameObject Bomb_Explosion)
     {
         if(Bomb_Explosion.name == "Player")
         {
             Destroy(GameObject.Find("Player"));
             GameTimer.Game_Seconds = 59;
             GameTimer.Game_Minutes = 4;
             Application.LoadLevel ("Game_Play_1");
         }
         if(Bomb_Explosion.name == "AI_One")
         {
             Destroy(GameObject.Find("AI_One"));
         }
 }

I have added two Images, the first is destroying the crate object, i placed that bomb into border of the crate. If i place that bomb into center of the crate, its like 2nd Image.

destroyed.png (321.6 kB)
destroy_1.png (327.9 kB)
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

2 Replies

  • Sort: 
avatar image
0
Best Answer

Answer by Prasanna · Dec 04, 2014 at 04:59 AM

Here it is, i found a way to fix this.

 if(Input.touchCount > 0)
         if(Bomb_Button.HitTest(Input.GetTouch(0).position))
         {
 
             if (Instance == true)
             {
                 Bomb_Temp = Instantiate(Bomb, Bomb_Place.transform.position, Quaternion.Euler(0, 0, 0)) as GameObject;
                 Explosion_Position = Bomb_Temp.transform.position;
                 Explosion_Rotation = Bomb_Temp.transform.rotation;
                 Bomb_Click = true;
                 Instance = false;
             }            
         }
         
         if(Bomb_Click == true)
         {
             Bomb_Time += Time.deltaTime;
             if(Bomb_Time >= 3f)
             {
                 Destroy(Bomb_Temp);
                 Bomb_Time = 0;
                 Bomb_Click = false;
                 Bomb_Visible = true;
                 Expose_Instance = true;
             }
         }
         
         if(Bomb_Visible == true)
         {
             if(Expose_Instance == true)
             {
                 audio.PlayOneShot (Explosion_Sound);
                 Explosion_Temp = Instantiate (Explosion, Explosion_Position, Explosion_Rotation)as GameObject;
                 Expose_Instance = false;
             }
             Explosion_Time += Time.deltaTime;
             if(Explosion_Time >= 2f)
             {
                 Destroy(Explosion_Temp);
                 Explosion_Time = 0;
                 Bomb_Visible = false;
                 Instance = true;
             }
         }
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
avatar image
1

Answer by zero3growlithe · Jun 23, 2014 at 10:22 AM

I assume you assigned this script above to the ParticleSystem, the problem here is that OnParticleCollision is called on the object that got hit by the particle (remember to have collisions and Send Collision Message checked in the particle system). So, in order to make it work you need to add a tag to the ParticleSystem explosion like "explosion" and add a script to each object that should react to particles like:

 void OnParticleCollision (ParticleSystem explosion){
     if (explosion.gameObject.tag == "explosion")
         Destroy(gameObject);
 }

http://docs.unity3d.com/ScriptReference/MonoBehaviour.OnParticleCollision.html

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

Follow this Question

Answers Answers and Comments

22 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

Related Questions

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

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

Destroy clone when left Field of view? 1 Answer

Destroy object before end of Awake function 1 Answer

Collect and Use Object 0 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