Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 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 /
  • Help Room /
avatar image
0
Question by jigwiz · Jul 02, 2017 at 12:18 AM · instantiate3dparticle systemshooterexplosion

How do execute explosion when instantiated object hits a particle?

I'm making a 3d shooter game. I have a particle system thats spawning large rock meshes towards the player. The player shoots/instantiates spheres to destroy the particles and also displays explosion prefab on impact. I have explosion script attached the spheres that causes them to explode and disappear when they hit an object. The problem is that the particle system is not responding as it should be when hit by the spheres. 1st Some bounce off the spheres, 2nd some particles are destroyed by the spheres, they just vanish, 3rd sometimes the spheres go through the particles and I have to shoot multiple times before the particle either is destroyed or bounces off. But through all of this the the explosion doesn't execute when hitting particles and is not destroyed.

I tested the explosions by creating a cube in the scene and shooting it. The explosion executes and the sphere is destroyed on impact. Also the particles are bouncing off all other meshes in the scene. Im not sure what exactly I am missing to get this to work properly.

Explosion script attached to spheres:

 public class Explosion : MonoBehaviour {
 
     public GameObject explosion; // drag your explosion prefab here
 
     // Use this for initialization
     void Start () {
         
     }
     
     // Update is called once per frame
     void Update () {
         
     }
     void OnCollisionEnter(){
         GameObject expl = Instantiate(explosion, transform.position, Quaternion.identity) as GameObject;
         Destroy(gameObject); // destroy the sphere
         Destroy(expl, 3); // delete the explosion after 3 seconds
 
 }
 
 }

Heres script that shoots projectile spheres attached to empty game object:

 public Rigidbody ball;
     public float bulletSpeed;
     // Use this for initialization
     void Start () {
         
     }
     
     // Update is called once per frame
     void Update () {
 
         if (Input.GetButtonDown ("Fire1")) {
             Rigidbody newBall;
 
             newBall = Instantiate (ball, transform.position, transform.rotation) as Rigidbody;
             newBall.velocity = transform.TransformDirection (Vector3.forward * bulletSpeed);
 
         }
         
     
 }
 }

I have "Trigger" enabled on particle system, and particles are set to be destroyed when the touch sphere object.

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

Answer by jigwiz · Jul 03, 2017 at 05:30 PM

So to simplify my question, I want particles to be destroyed when an instantiated object hits that particle. I found that the trigger to destroy a particle on contact with rigid body works IF I disable collision in the particle system. Yet I have a sphere object that the one in the scene will destroy a particle but not the INSTANTIATED spheres.

What am I missing?

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

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

127 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 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 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 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 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 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

How do I destroy a single particle when it collides with a certain object 0 Answers

3D object Fade in effect 0 Answers

mechanics from Sky Force of shooting 0 Answers

Why more balls are instantiating? 0 Answers

Instantiate GameObject with nested Particle Systems 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