Hello All,
I am haveing an odd problem with my character controller and some strange scaling issues when I set the parent to certain objects.
In my controller script:
function OnControllerColliderHit (hit : ControllerColliderHit)
{
if (hit.moveDirection.y < -0.4) {
transform.parent = null;
transform.parent = hit.gameObject.transform;
print ("change parent" + transform.parent);
return;
}
This is so that my character can ride all the various moving platforms and things of that nature. This works great most of the time. However I have begun to try and optimize a bit by replacing complicated mesh colliders with a handful of primitive box colliders. (I am just making new cube game objects and positioning them in the right place and then turning off the mesh renderer)
ok, so this brings me to my problem:
sometimes when I hit one of the cube primitives (and subsequently it becomes my parent) the scale of my controller will get all wacky.
I have attached an example image. (the images seem to be in the wrong order, oh well) the first image shows the ‘after’ the second image is the ‘before’
I have turned on all the rendering for all the box colliders so that they are easier to see. Anyhow, my character (the little snowball) drives through the first set of colliders without trouble, and i can drive all over that left hand group of collider all day long and nothing odd happens.
However, as soon as I get down to the right hand boxes, as soon as i collide with it, my scale gets set to some fairly random value.
If i trash all the box colliders and just use the mesh colliders, then it works great…
Any ideas what I am doing wrong here?
Cheers! and THanks!
-ben
ps: i just tried one more thing: if I take the right hand collider and set the x and z rots to 0, then everything is fine again, (except that it defeats the purpose of that object in the scene, which requires a ramp) but if i change one of the x or z rotations to 1 degree even, then i get strange scaling issues. (which seems to be why the left hand set of colliders is fine, they are only rotated about the y axis)
I guess if this is impossible to do, I can just use the mesh colliders for anything that has a slope to it…