ColliderのConvex設定 Unity
ColliderのConvex設定にチェック入れるとメッシュコライダーが、チェックしたときのメッシュの形にあわせて変形する。変形された形は維持される。
→動的にチェックのオンオフしたい。
http://unity3d.com/support/documentation/ScriptReference/MeshCollider-convex.html
↑のURLを参考に
transform.collider.convex = true;
・・・としたがエラー。
error CS1061: Type `UnityEngine.Collider' does not contain a definition for `convex' and no extension method `convex' of type `UnityEngine.Collider' could be found (are you missing a using directive or an assembly reference?)
MeshCollider meshCollider = GameObject.Find("コライダーのあるゲームオブジェクト").GetComponent<MeshCollider>(); meshCollider.convex = true;
Update関数内とかでこうすれば、動的にコライダーの形状が変化した。
ここにもある
http://forum.unity3d.com/threads/32467-How-to-update-a-mesh-collider