1.I have some custom worlds and need to set physics systems to my custom system group in FixedUpdate,like this:

My many systems can’t and no need to run in default world,so I set DefaultGameObjectInjectionWorld to empty:
#if !GAME_RESOURCE_EDIT
public class GameBootStrap : ICustomBootstrap
{
public bool Initialize(string defaultWorldName)
{
var world = new World(defaultWorldName);
World.DefaultGameObjectInjectionWorld = world;
return true;
}
}
#endif
2.I have multiple worlds and need to set a entity to a specify world,but current version built-in conversion systems can’t do this well(maybe it’s my misunderstand), so I custom conversion systems seem as GameObjectEntity,like this:

3.I believe unity can improve these issues in the future. but it’s so long for my game.I think the two method can give me more possibility.
This is my current Implementation:
public static BlobAssetReference<Unity.Physics.Collider> Convert(this PhysicsShapeAuthoring shape, int groupIndex, bool isBaked)
{
quaternion rotation;
var transform = shape.transform;
var localToWorld = transform.localToWorldMatrix;
var shapeToWorld = shape.GetShapeToWorldMatrix();
var blob = BlobAssetReference<Unity.Physics.Collider>.Null;
switch (shape.ShapeType)
{
case ShapeType.Box:
var boxGeometry = shape.GetBoxProperties();
if (isBaked)
{
var orientation = EulerAngles.Default;
orientation.SetValue(boxGeometry.Orientation);
boxGeometry = boxGeometry.BakeToBodySpace(localToWorld, shapeToWorld, orientation);
}
blob = Unity.Physics.BoxCollider.Create(
boxGeometry,
GetFilter(shape, groupIndex),
GetMaterial(shape));
break;
case ShapeType.Capsule:
var capsuleGeometryAuthoring = shape.GetCapsuleProperties();
if (isBaked)
capsuleGeometryAuthoring = capsuleGeometryAuthoring.BakeToBodySpace(localToWorld, shapeToWorld);
blob = Unity.Physics.CapsuleCollider.Create(
capsuleGeometryAuthoring.Get(),
GetFilter(shape, groupIndex),
GetMaterial(shape));
break;
case ShapeType.Sphere:
var sphereGeometry = shape.GetSphereProperties(out rotation);
if (isBaked)
{
var orientation = EulerAngles.Default;
orientation.SetValue(rotation);
sphereGeometry = sphereGeometry.BakeToBodySpace(localToWorld, shapeToWorld, ref orientation);
}
blob = Unity.Physics.SphereCollider.Create(
sphereGeometry,
GetFilter(shape, groupIndex),
GetMaterial(shape));
break;
case ShapeType.Cylinder:
var cylinderGeometry = shape.GetCylinderProperties();
if (isBaked)
{
var orientation = EulerAngles.Default;
orientation.SetValue(cylinderGeometry.Orientation);
cylinderGeometry = cylinderGeometry.BakeToBodySpace(localToWorld, shapeToWorld, orientation);
}
blob = CylinderCollider.Create(
cylinderGeometry,
GetFilter(shape, groupIndex),
GetMaterial(shape));
break;
case ShapeType.Plane:
float3 v0, v1, v2, v3;
shape.GetPlaneProperties(out var center, out var size, out rotation);
{
var orientation = EulerAngles.Default;
orientation.SetValue(rotation);
if (isBaked)
{
PhysicsShapeExtensions.BakeToBodySpace(
center,
size,
orientation,
localToWorld,
shapeToWorld,
out v0,
out v1,
out v2,
out v3);
}
else
{
PhysicsShapeExtensions.CalculatePlanePoints(
center,
size,
orientation,
out v0,
out v1,
out v2,
out v3);
}
}
blob = PolygonCollider.CreateQuad(
v0,
v1,
v2,
v3,
GetFilter(shape, groupIndex),
GetMaterial(shape));
break;
case ShapeType.ConvexHull:
using (var pointCloud = new NativeList<float3>(65535, Allocator.Temp))
{
shape.GetConvexHullProperties(pointCloud);
if (isBaked)
shape.BakePoints(pointCloud);
ConvexCollider.Create(
pointCloud,
shape.ConvexHullGenerationParameters,
GetFilter(shape, groupIndex),
GetMaterial(shape));
}
break;
case ShapeType.Mesh:
const int defaultVertexCount = 2048;
using (var pointCloud = new NativeList<float3>(defaultVertexCount, Allocator.Temp))
using (var triangles = new NativeList<int3>(defaultVertexCount - 2, Allocator.Temp))
{
shape.GetMeshProperties(pointCloud, triangles);
if (isBaked)
shape.BakePoints(pointCloud);
blob = Unity.Physics.MeshCollider.Create(
pointCloud,
triangles,
GetFilter(shape, groupIndex),
GetMaterial(shape));
}
break;
default:
break;
}
return blob;
}
Bake collider need the transform.localToWorldMatrix,sometime my game have the same collider but in different hierarchy between server and client.
it give me two different colliders even if i make sure they have the same transform in world space.