物体是绕其物理碰撞器轴旋转的,因为物理碰撞器驱动着它们的运动。这是您可以“消除”对撞机方向的方法:
Entities
.WithBurst()
.WithAll<PhysicsVelocity, PhysicsMass>()
.ForEach((ref PhysicsVelocity velocity, in PhysicsMass mass) =>
{
velocity.Angular = math.transform(math.inverse(mass.Transform), new float3(0, 0, 1));
})
.ScheduleParallel();
使用DOTS执行多线程Capsule Collider转换的正确方法:
//在.ForEach之前添加.WithReadOnly(world),这将使世界变为只读
World world = World.DefaultGameObjectInjectionWorld;
BuildPhysicsWorld buildPhysicsWorld = world.GetExistingSystem<BuildPhysicsWorld>();
PhysicsWorld physicsWorld = buildPhysicsWorld.PhysicsWorld;
CollisionWorld collisionWorld = physicsWorld.CollisionWorld;
Entities.WithReadOnly(collisionWorld).ForEach((Entity e, ref Translation translation, ref Rotation rotation) =>
{
// Your code here for casting colliders
ColliderCastHit hit = new ColliderCastHit();
bool haveHit = collisionWorld.CastCollider(c, out hit);
});
网友评论