- Home /
Collision problems (character controller - mesh collider)
Ok, I am making a 2.5 platformer in which I used a first person object and by script, gave it the necessary behaviors so it plays like a side scrolling platformer. For collisions the object has a character controller.
I started to build a level which has several rotating gears where the player needs to time the jumps in order to get onto the next one and so on. The gears have mesh colliders.
The thing is that when I apply rotation movement on the "gears" it somehow screws up the collision detection. It seems that when the character lands on the gear's teeth there is no problem, but as soon as I move it and the character falls into the space between the gear's teeth, it goes through.
Details:
-The gears were made in blender (extra object/gear) and I made them look solid by merging the vertices on the donut shape of the gear so it looks as if its solid.
tested collisions without the gears rotating (static) and it gives no problems.
-Tried increasing the slope limit on the character, but that didn't solve anything.
My guess is that this has something to do with the rotation of the gears or the fact that the gears have a donut shape and are not solid on the inside.
Any help will be greatly appreciated, thanks in advance Unity community!
Answer by aldonaletto · Feb 28, 2013 at 11:56 AM
Maybe this is due to a known problem with the CharacterController: it tends to fall through platforms that move up. A common workaround for this issue is to keep the CharacterController moving all the time at a ridiculous speed - for instance:
function Update(){
var cc = GetComponent(CharacterController);
cc.Move(Vector3.forward * 0.0001 * Time.deltaTime);
// rest of Update code
}
This code moves 0.1 milimeter per second in the world Z direction, a hardly noticeable movement - but big enough to do the magic.
It did not work, the character does move a little but it is still falling through.
UPDATE I fixed it! It seems that the gear was indeed hollow on the inside and that was the reason why the character was going through. I just went into blender and embedded a cylinder inside of it so it served to make it thicker and now it works perfectly
Thanks anyway :)
Your answer
