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 FatWednesday · Oct 26, 2012 at 04:20 PM · physicsrigidbodycollidercollisions

Collisions occassionaly fail.

Ok, so i've had a look at a few other "collision not working" posts, but have yet to find a solution that works for me.

Also, as a note, this issue is not a constant issue, it seems to happen very occasionally, and so is a pain to reproduce.

I have an object with a sphere collider, a rigid body using gravity, and then a second object with a collider set to a trigger. the rigidbody object is flung at the other (and the trigger object, and speeds of the flung object should not be creating the bullet through paper problem), The object hits the collider and fires collisions properly 9/10 times, but that 1/10 times it just flies straight through, without calling the collision. (i've tried this using all 3 collision modes on the rigid body, and various levels of solver itterations in physics settings).

Granted, this could just be one of those issues where in very perfect conditions, the fling of the object gives it just enough force to go through the collider. but with the rarity of it, and the scaling attempts i've made to the collider cause me to doubt this possibility a lot.

Does anyone else have any idea what might be causing this issue?

Comment
Add comment · Show 6
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 Fattie · Oct 26, 2012 at 04:43 PM 0
Share

how big are the objects in meters? (or in abstract unity measures)

how much do they weigh? how fast m/s ? could you post a pic ?

avatar image FatWednesday · Oct 26, 2012 at 04:49 PM 0
Share

(measurements based on a default unity cube object being 1x1x1) the flung object (with rigid body and collision code) sphere collider is approximately 0.4 units in diameter. The trigger collider has been tested at a range of depths approximately 0.5 units to 3 units. speed I'm unsure of, will try and get a read out of that when I get the chance.

avatar image Fattie · Oct 26, 2012 at 04:55 PM 0
Share

is the trigger a cube ... it's about the same size? it's not tiny, huge ?

avatar image FatWednesday · Oct 26, 2012 at 05:00 PM 0
Share

The trigger is not a cube, it's a mesh collider. Without scaling it's about 1 unit deep

avatar image Fattie · Oct 26, 2012 at 05:02 PM 0
Share

have you marked it as concave - convex - or whatever the hell that setting is.

read up on the mesh collider gotchya.

generally never use mesh colliders, other than maybe for an uneven ground

Show more comments

4 Replies

· Add your reply
  • Sort: 
avatar image
0
Best Answer

Answer by sparkzbarca · Oct 29, 2012 at 10:57 AM

mark the collision Detection in rigidbody as continous dynamic for both objects and try it.

http://docs.unity3d.com/Documentation/Components/class-Rigidbody.html

read up about it some there.

You don't want to use that setting but you can probably use it to rule out the object "flying" through it because of the projectile speed.

If it doesn't go through with them set to that after 50 tosses then you know it is in fact flying through undetected.

You might also simply slow the object down, the simple fact is if it always triggers at 1mph and only sometimes triggers at 2, like it or not its the mph difference. Lastly of course you can way exagerate the size of the collision box, make it 10 or 20 times as deep where its being hit.

So go ahead and slow it WAY down or make the box WAY big to make certain this isn't the issue not just you doubt it is.

It sounds like it is in fact exactly the issue because you are getting collisions just not all the time.

Comment
Add comment · Show 3 · 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 FatWednesday · Oct 29, 2012 at 11:11 AM 0
Share

Only the projectile object has a rigid body, the other is just a collider acting as a trigger region, but we're already using the continuous dynamic on the projectile.

I've slowed the projectile down as much as I can (it really isn't going fast at all, any slower looks ridiculous) Atm the bug seems now to be firing more rarely, so clearly I was wrong and the collision checks happen slower than I thought (my doubt on the speed thing was purely based on the trial and error of making the collider far deeper than it needed to be).

If I lower the fixed update time I should be able to gradually increase the speed of the projectile back up shouldn't I? (shouldn't be a cost concern since this is the only physics thing in the scene).

avatar image sparkzbarca · Oct 29, 2012 at 07:01 PM 0
Share

quote

"...so you might still consider decreasing the fixed Time step value in the Time$$anonymous$$anager inspector to make the simulation more precise, if you run into problems with fast moving objects."

so yea also i mean how fast is this thing going? Basically the default speed should be 60 frames per second.

Are you telling me it looks silly but its passing through the object in 1/60th of a second, cause thats like, thats fast.

Do some basic math and note that a cube in unity is 1 meter.

Lets look at an example math

100mph object 100 mph = 146 feet per second 146 fps = 2.43 feet pet 60th of a second (146 / 60)

thats roughly a meter or equal to 1 unit in unity.

is your hitbox width less than the width of the square primitive? is your object such that you feel 100mph is slow? (a car certainly isnt but a bullet is)

avatar image FatWednesday · Oct 30, 2012 at 10:23 AM 0
Share

oh no it isn't going that fast. with my catcher set to approximately 2 units/meters wide, the object is taking about 30 upates (so half a second) to pass through the depth of the catcher. But in the last day I've only noticed the "miss" about 2 times, in probably near 200 tests, so I'm happy enough to be done with this problem.

avatar image
0

Answer by honkzor · May 25, 2017 at 04:19 PM

I am having the same issue, I am writing an arcade style space shooter where collisions need to be perfect. No luck so far, although the problem appears only once in 5 minutes playtime or so (many collisions in that time)...

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 bigChris · Aug 12, 2017 at 01:07 PM

Had a similar issue. The Player asset designer had added box colliders to each component of the Player asset and then an overall box collider to the entire object. Apparently, that was just a bit too much for the engine to comprehend. Removing all the individual box colliders and just sticking with one overall solved the issue...

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 FullHeartGames · Feb 25, 2020 at 04:07 AM

If you do not want to alter fixed update time another solution is to monitor the projectile or w/e for a collision by its velocity. Basically once the velocity slows down by a minimum of 'x' amount there was likely a collision. Here is my solution to this, I am checking for a collision or change in velocity.

 private void OnTriggerEnter2D(Collider2D collision)
 {
         anyCol = true;
 }
 
 public IEnumerator DoUntilUntilCol()
 {
     anyCol = false;
     float lastVel = 0;
     float curVel = 0;
     
     while (!anyCol || curVel < lastVel)
     {
         curVel = rig.velocity.magnitude;
         Debug.Log("VELOCITY: " + rig.velocity.magnitude);
     
         if (curVel >= lastVel)
         {
             lastVel = curVel;
         }
     
         yield return new WaitForFixedUpdate();
      }
     
      DoSomethingElse();
      yield return null;
 }
 
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

13 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

Related Questions

My object falls through terrain. 8 Answers

Character Controller Pushes Car With Wheel Colliders? 0 Answers

How do I detect current collisions without using onCollisionEnter? 0 Answers

Player keeps bouncing off the walls 2 Answers

How to setup character Collisions? 2 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