mesh collider

for my 2d game i have modelled platforms in maya. To make things look more dynamic i added bumps and grooves in my platforms. I want my player to angle itself according to these bumps and grooves when walking over them.

i currently have a script to angle the player which occurs on collision enter with other objects with box colliders:

playerTransform.rotation = Quaternion.Slerp(playerTransform.rotation, col.transform.rotation, speed);

However this seems to have no effect for my platform…which is a mesh collider. Is there no way to do this for my platforms then? I dont want to replace my mesh collider with multiple box colliders instead since thats going to be quite a teadious job for me.

Thank you

What you need is not the rotation of the collider itself, but of the individual triangle your player is on. The easiest way I can think of is to do a raycast to the floor and obtain the surface normal. Something like:

Ray ray = new Ray(playerTransform.position, -Vector3.up);
RaycastHit hit;
Vector3 surfaceNormal = Vector3.up;
if(Physics.Raycast(ray, out hit))
    surfaceNormal = hit.normal;
playerTransform.up = surfaceNormal;