i have a sphere that’s completely flying through certain points of a mesh collider. i looked around and read a few things about Update vs Fixed Update but i’m not sure how that applies to what I’m doing because it’s just a rigid body sphere colliding into a mesh… 95% of the time it works fine but occasionally one slips through. seems like it’s be a common problem with a simple fix. any ideas?
I’ve seen this as well. In testing, I made the colliders that were being breached much bigger and slowed down the speed of the objects, and this solved the problem.
I believe what is happening is that the object is passing thru the other object in the time between collision detection passes. Its on one side in one frame and the other in the next.
Don’t have too high speeds unless you are willing to raise the collision iteration count as well.
Also very small triangles will cause problems due to restricted accuracy in floats.
would raising the collision iteration count significantly reduce the framerate? how could i change this to test?
Also try reducing Edit > Project Settings > Physics > “Min Penetration For Penalty”. This will prevent objects from penetrating at high speeds and/or small tolerances.
thanks - i’ll try that but it’s one of those things that’s gonna be hard to know for sure since I can’t consistently duplicate.
There are some ray-casting solutions to this as well, but I’ve not kept track of them nor tested them. From what I remember you use the ray cast to look ahead and use your object’s current speed to calculate whether your object will have passed through the collider on the next frame and forcing the collision somehow - but I could be making that up - and I’m not sure how you “force” behaviour into OnCollisionEnter(), etc…
The error is definitely due to smaller objects and larger speeds not actually CONTACTING the collider on an active update, and thus passing through the collider “between” the frames. I saw this first back in Unity 1.o when I was fisrt testing and lurking. Rocket Grenades had a common tendency to fly through the walls of the FPS station in the FPS tutorial. Frankly, now though, I can’t remember what I did to solve it back then…
I have this problem on occasion in my current game, but the scheduled fix date is on a sticky note somewhere… so if you come up with an answer, could you post it here, and I’ll do the same?
You move the object to the position where the raycast hit, so the next frame it will be guaranteed to be contacting the collider. (Assuming static geometry anyway…I don’t think that would work for two fast-moving objects.)
If you increase the physics timestep, then objects don’t move as far between physics frames, so there’s a higher chance of colliding and not passing through. Of course, this also uses more CPU since physics are calculated more often.
–Eric
You know, this isn’t an iPhone Development problem, it’s a general Support problem. I realized over supper that I was recounting my tales of the v1.o FPS tutorial. This question should be searched for/posed in the Support forum…
The best way to address this may be influenced by the target platform (iPhone), but I agree that this is most likely not iPhone specific, so I’m moving this to Support since suggestions and information in this thread may be useful to a broader range of users.
Just started my search for an actual solution, starting at the wiki…
And Lo! The wiki spaketh:
Tho I hast not yet triedeth it, I have goblet loads of faith…