x


Character collider / physics bug in Unity 3.3 - falling through terrain / objects

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...

more ▼

asked Apr 07 '11 at 04:22 PM

BrianWinn gravatar image

BrianWinn
86 2 3 6

You may have to use the bug reporter. Go to help ~> report a bug (which is right at the bottom)

Apr 07 '11 at 04:26 PM AngryOldMan

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 :(

May 29 '11 at 08:19 AM Meltdown

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.

May 29 '11 at 02:15 PM aldonaletto

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.

Jun 15 '11 at 09:22 PM QuantumRyan

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.

Oct 25 '11 at 02:33 PM Waz
(comments are locked)
10|3000 characters needed characters left

3 answers: sort voted first

I think this has to do with the slope limit.

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.

more ▼

answered Nov 10 '11 at 08:33 AM

gordieross gravatar image

gordieross
1

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.

Nov 10 '11 at 09:57 AM Waz
(comments are locked)
10|3000 characters needed characters left

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.

more ▼

answered Nov 10 '11 at 11:19 AM

gordieross gravatar image

gordieross
1

(comments are locked)
10|3000 characters needed characters left

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.

more ▼

answered Jan 05 '12 at 05:42 AM

stu gravatar image

stu
1

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).

Jan 10 '12 at 12:09 AM Waz
(comments are locked)
10|3000 characters needed characters left
Your answer
toggle preview:

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

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Topics:

x1870
x1472
x672
x97

asked: Apr 07 '11 at 04:22 PM

Seen: 4137 times

Last Updated: Jan 10 '12 at 12:09 AM