Last active
February 13, 2019 16:05
-
-
Save EternalTamago/8c90f8e2646fce91be82f3a8d61fdcba to your computer and use it in GitHub Desktop.
実行時にアセットではなくコードからConvexHullColliderShapeを作成する
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // 実行時に頂点とインデックスからConvexHullColliderShapeを作成する(凸包の頂点とインデックスはVHACD/VHACDSharpか自前で用意しておく) | |
| // PhysicsComponentがシーンから削除されても作成されたColliderShapeは破棄されてないので注意 | |
| var staticCollider = new StaticColliderComponent(); | |
| var convexDesc = new ConvexHullColliderShapeDesc | |
| { | |
| ConvexHulls = new List<List<List<Vector3>>> { new List<List<Vector3>> { new List<Vector3>(points), }, }, | |
| ConvexHullsIndices = new List<List<List<uint>>> { new List<List<uint>> { new List<uint>(indices), } }, | |
| }; | |
| staticCollider.ColliderShapes.Add(new ColliderShapeAssetDesc { Shape = new PhysicsColliderShape(new[] { convexDesc }), }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment