Skip to content

Instantly share code, notes, and snippets.

@EternalTamago
Last active February 13, 2019 16:05
Show Gist options
  • Select an option

  • Save EternalTamago/8c90f8e2646fce91be82f3a8d61fdcba to your computer and use it in GitHub Desktop.

Select an option

Save EternalTamago/8c90f8e2646fce91be82f3a8d61fdcba to your computer and use it in GitHub Desktop.
実行時にアセットではなくコードからConvexHullColliderShapeを作成する
// 実行時に頂点とインデックスから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