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 /
avatar image
0
Question by memblock · Feb 09, 2017 at 04:07 PM · rigidbodyparticlesparticlesystem

Remaining bullets ridgidbody bounses of after the enemy has been destroyed.

Hi!

In my game you control a ship that can fire at enemy ships, thus destroying them. When the bullet hits the enemy it is destroyed in code, and instanciates an explosion particle effect. The bullet, upon impact is also destroyed. So far, so good but the problem is that if I fire another bullet that 'hits' before the particle effect is done playing it bounces off. I have tried removing the particle effect and then It works the way I want it so I suspect it's because the bullet collides with the particles collider? If so, how can i disable the particles collider? or should/must I use the collision matrix?

My code looks like this: The bullet

 if (Input.GetKeyDown (KeyCode.Space)) 
         {
             TEMProtation = new Vector3 (90, 0, 0);
             bulletStart = new Vector3 (myTransform.position.x, myTransform.position.y, myTransform.position.z + 1);        //bullet spawnPos
             bulletClone = spawn.ExSpawnObject(bullet,bulletStart,Quaternion.Euler(TEMProtation));
         }

The collision:

 void OnCollisionEnter(Collision col)
     {
         if (col.gameObject.tag == "enemy") 
         {
             Destroy (col.gameObject);
             Destroy (this.gameObject);
         }
     }

The particle effect is instantiated from the enemies OnDisable() event:

 public void OnDisable()
     {
         spawn.SpawnObject (explosionPrefab, myTransform.position, Quaternion.identity);
         sound.PlaySound (4);
     }



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

· Add your reply
  • Sort: 
avatar image
0

Answer by MarshallN · Feb 09, 2017 at 07:15 PM

Check your explosionPrefab to make sure it doesn't have a collider, first.

Also, are you sure you want your bullet to have a RigidBody? If you just have a collider on it and have it be a trigger, it would pass through any object that doesn't destroy it by default.

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
0

Answer by memblock · Feb 09, 2017 at 07:15 PM

I think I solved this. The particle itself has a script attached called "Explosion physics force" Which seems to add force to the rigidbody. I disabled it, and now it works.

Comment
Add comment · Show 1 · 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 memblock · Feb 11, 2017 at 10:56 PM 0
Share

heres a youtube video of my solution: https://www.youtube.com/watch?v=O$$anonymous$$O3ef6eN8$$anonymous$$

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

5 People are following this question.

avatar image avatar image avatar image avatar image avatar image

Related Questions

Is it possible to make a particle system solid??? 2 Answers

make particles move in world space 1 Answer

Can you change the Velocity Over Lifetime of a Particle System using a Script? 3 Answers

how to make bag filled with water that can be moved by physics? 0 Answers

Shuriken particle System - change velocity by trigger 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