• 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 Farmerfromtexas · Dec 16, 2021 at 02:33 PM · collisionphysicssizeprojectileaddexplosionforce

AddExplosionForce makes affected object collide with everything at once?

Hello friends!

In my project I can throw a projectile (with Force) that I can also pick up again. The collision detection on the projectile is set to continuous dynamic. On collision with an enemy, the projectile becomes kinematic and after a timer the enemy explodes and emits an explosion force to nearby objects:

 private void OnDestroy()
 {
     if (projectile != null)
     {
         projectile.GetComponent<Rigidbody>().isKinematic = false;
     }

     Collider[] colliders = Physics.OverlapSphere(transform.position, explosionRadius);
     foreach (Collider inRange in colliders)
     {
         Rigidbody rb = inRange.GetComponent<Rigidbody>();
         if (rb != null)
         {
             rb.AddExplosionForce(explosionForce, transform.position, explosionRadius);
         }
     }
 }

IsKinematic is set to false so the projectile is also affected by the explosion. One or two (or sometimes a few more) frames after the force explosion is called, the projectile returns a collision with (almost?) every single game object in the scene including every other enemy; triggering a chain reaction of explosions. This, of course, is not a welcome feature... Other gameObjects affected by the explosion do not share this problem.


The projectile's collider has the size of a parentless cube with scale (0.02564212, 0.08199235 0.6880991). When I scale the projectile to be larger it seems to fix the issue, suggesting it might be too small for the physics engine to handle properly... But the force added to the projectile when throwing it does not create this problem and making it larger would be really inconvenient.
Is there a way I could make this work?

Comment
Add comment · Show 2
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 Statement · Dec 16, 2021 at 09:56 PM 0
Share

It's been a while since I used Unity so I don't know if this is relevant information any longer but in the past at any rate, and if I remember correctly, there used to be issues with using non-uniform scale (that is when xyz scale is not the same across each of the values). As a test, if possible, try making your colliders scale uniform.

avatar image Farmerfromtexas Statement · Dec 17, 2021 at 10:32 AM 0
Share

Hey @Statement, thanks for your reply! :) I did not realize non-uniform scaling was so undesirable. I changed the Scale Factor of the model Import Settings (to 2.5 in case that's relevant) so that the game object has a uniform scale of 1 in the scene. I tried giving the Box Collider different uniform scales (also tried a compound collider consisting of multiple uniform box colliders on child objects along the mesh to fit the shape, which felt weird when opposed to just one non-uniform box collider) but sadly, the problem persists at the lower scale I'm ai$$anonymous$$g for.

What remains true is that the bigger I make the collider, the less the problem occurs... Suggesting the projectile is just too small for (explosion?) force to apply correctly. even though it does not seem that small from my subjective point of view... :p

Still don't really know how I would tackle the issue.

0 Replies

· Add your reply
  • Sort: 

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

257 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 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 avatar image avatar image avatar image

Related Questions

Innacurate terrain collision with fast rigidbody 1 Answer

Projectiles, their speed, and collisions 1 Answer

Bullet projectiles with collision info without affecting others 0 Answers

Collision occurring when it should not! Help! 1 Answer

Giving Instantiated Object Velocity Causes Wrong Position 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