I am working on a large 3rd person game project in Unity. We started in 2.6 and everything was working great. When we upgraded to Unity 3.3, we started to have an issue where the player, at seemly random times would just fall through the world. The funny thing is that when this happened, not only the player would fall through but other NPCs (with Character Controllers on them) would do the same at the exact same time.
When running in the editor, I would pause, raise the player and other NPCs above the terrain and hit play again. The player (and other NPCs) would then just keep falling, right through the terrain (both Unity terrain and externally modeled objects with mesh colliders.) If I manually put a cube or plane below the character with the standard colliders it stops as it should. It is almost as if Physics/colliders completely broken between the character controller and the terrain (or externally modeled terrain with mesh colliders) in the game.
I read some other posts that said you should delete the character controller and re-add it after upgrading to Unity 3. I did this but the problem still persists.
To be clear, the player works fine 95% of the time. The other 5% it just falls through the world (as described above.) Unfortunately we have burned 40 hours trying to diagnose and solve this problem. I am 99% certain that the issue is with Unity itself and not our setup or code.
We need to resolve this ASAP as we need to release the game. Any help would be greatly appreciated.
UPDATE: The problem seems to happen more often when we delete game objects with colliders on them. For example, we delete arrows that have been shot after a period of time. Deleting these colliders seems like it may be causing holes in the terrain mesh collider. Very strange...
You may have to use the bug reporter. Go to help ~> report a bug (which is right at the bottom)
I've found Unity to have numerous issues with mesh colliders. In most cases I find using box and other simpler colliders tends to solve the problem. But in most cases this is not feasible :(
I've been experiencing a similar problem. I'm developing a game in my notebook, and when the frame rate falls to a ridiculous level (3 fps or less) something strange happens. First, some coins - simple objects with spherical colliders - start to be "taken" by the player - but the player is stopped far from them, and it should only happen if an object named "player" entered their colliders. A few seconds later, the player itself falls through the ground.
It's not an experience directly related to Unity and its colliders, but I've seen this same behavior before. In my case, it was a simple terrain mesh and some characters and NPC would just fall through, seemingly randomly. The culprit was a 2 vertex "triangle". I'm not sure why exactly, but the code we were using didn't like it. I'm not sure if Unity collision works even remotely similar, but its worth taking a look at your mesh(s) for lines and ngons.
I'm getting a very similar problem - especially the infrequency of it (things that collided fine suddenly do not), and I hide and show (via GameObject.active). Interestingly though, all my colliders are primitives - mainly BoxCollider.
When something collides with the Controller capsule, the capsule thinks it is another platform.
I fixed this problem in my game by adding tags to the things I didn’t want the Player to treat as a slope.
If the player collides with any of them, I set the Slope limit to 180 degrees, else I set it back to the original value in the script.
That seems completely unrelated. Are you saying that without such action, your characters fall through or penetrates those objects? If so, can you explain how slope limit effects it? If not, could you please delete this answer. Hopefully it is the former and we are onto a solution. My understanding is that slope limit either stops objects (too steep) or lifts them (up slope). Never does it make objects non-collide.
When I have terrain beneath my Character Controller capsule and it bumps into a sphere above it, it momentarily seems to ignore the fact that it is still colliding with a target below it.
I’ve fixed my problem where my CharacterController was falling through the terrain by adding to the OnControllerColliderHit function in PlatformerController.
function OnControllerColliderHit (hit : ControllerColliderHit)
{
if (hit.moveDirection.y > 0.01)
return;
// Make sure we are really standing on a straight platform
// Not on the underside of one and not falling down from it either!
if (hit.moveDirection.y < -0.9 && hit.normal.y > 0.9)
if (hit.collider.tag != "Ball")
activePlatform = hit.collider.transform;
if (hit.gameObject.tag == "Ball"){
if ((controller.transform.position.y-(controller.height/2)) < controller.collider.transform.position.y){
controller.slopeLimit = 180.0;
}
}
if (hit.gameObject.tag != "Ball"){
if (controller.slopeLimit != 45.0)
controller.slopeLimit = 45.0;
}
}
Without seeing the source code relating to CharacterController I can’t tell what exactly is going on, however this solution works in my case. If it is deemed not to be useful comment, then I will surely remove the posts.
I have a similar problem where, if I do something to one object (say add a collider, but no rigidbody) collision detects breaks for everything. No errors show up in the console window, nothing. If I revert the change, all of the sudden, everything starts working again. Right now I’m fighting with trees… as soon as I add a capsule collider to my tree pre-fab, everything breaks. Remove it, and it’s fine.
Sorry I can’t help with an answer, but this definitely seems like an issue with Unity. Even if I’m/we’re doing something wrong to one object, it should not:
silently hide any errors
break other, completely unrelated, objects
There must be something causing a singularity in the physics calculations or something.
My "fix" was to use less colliders, and perhaps adding the collider to your tree prefab means you have a lot of colliders. Still definitely a bug in Unity of course (if it was at least numerically documented and gave an error/warning they could call it a limitation).
Sorry to ressurect old thread, but hoping that someone could tell me how you solve this issue as i am also experiencing the same problem as OP.
I have 2 jungle scenes with quite a lot of trees, plants and rocks. The avatar/player and animals that both has character controller would just fall down the terrain(mesh model from 3DS Max)at any random time. And animals are using NAV mesh A-Star pathfinding. It didn’t happened before with just the avatar and 3D environment. But as soon we added/modified more stuff (eg: add quests and animals with pathfinding, change avatar system to mecanim). We have 2 other environments, which is just interiors, and they are fine. And this issue only happened in player, Not in editor
This is old, I know, but I have this very same problem with 4.3. Trying to find a solution...
We found a solution in our case for this same bug that was killing us for a month.
We had a dude with just a charactercontroller attached to him and a script to move it
All layers where correct
Terrain collider was correct
We never move him using transform.position but always charactercontroller.move
Yet randomly after a few minutes to hours it would just stop working (even ray casts preformed from that gameobject would stop working).
Then we attached a kinematic rigidbody not using gravity to the same gameobject as the charactercontroller and all of a sudden the bug stopped showing up. Even though it should be completely unrelated somehow this fixed it for us.
(also a very important note, do not change properties of the charactercontroller at runtime like slope limit, width and height, that gave us very unpredictable results).
You may have to use the bug reporter. Go to help ~> report a bug (which is right at the bottom)
– anon61858128I've found Unity to have numerous issues with mesh colliders. In most cases I find using box and other simpler colliders tends to solve the problem. But in most cases this is not feasible :(
– MeltdownI've been experiencing a similar problem. I'm developing a game in my notebook, and when the frame rate falls to a ridiculous level (3 fps or less) something strange happens. First, some coins - simple objects with spherical colliders - start to be "taken" by the player - but the player is stopped far from them, and it should only happen if an object named "player" entered their colliders. A few seconds later, the player itself falls through the ground.
– aldonalettoIt's not an experience directly related to Unity and its colliders, but I've seen this same behavior before. In my case, it was a simple terrain mesh and some characters and NPC would just fall through, seemingly randomly. The culprit was a 2 vertex "triangle". I'm not sure why exactly, but the code we were using didn't like it. I'm not sure if Unity collision works even remotely similar, but its worth taking a look at your mesh(s) for lines and ngons.
– QuantumRyanI'm getting a very similar problem - especially the infrequency of it (things that collided fine suddenly do not), and I hide and show (via GameObject.active). Interestingly though, all my colliders are primitives - mainly BoxCollider.
– Waz