Hello. I'm in process of making custom Kinematic Character Controller. I'm currently learning how to work with Unity Physics package and want to know why when I call CapsuleCast, using attached CapsuleCollider component, it detects itself?
Is there other ways of ignoring self collider besides specifying layer mask? I believe I'm misuing Physics API
[UpdateInGroup(typeof(FixedStepSimulationSystemGroup))]
[UpdateAfter(typeof(PhysicsSystemGroup))]
public partial struct CharacterControllerSystem : ISystem
{
public void OnCreate(ref SystemState state)
{
state.RequireForUpdate<PhysicsWorldSingleton>();
}
public void OnUpdate(ref SystemState state)
{
PhysicsWorldSingleton physicsWorld = GetSingleton<PhysicsWorldSingleton>();
CollisionWorld collisionWorld = physicsWorld.CollisionWorld;
foreach (var (lw, collider, _) in Query<RefRO<LocalToWorld>, RefRO<PhysicsCollider>, RefRO<CharacterController>>())
{
NativeList<ColliderCastHit> hits = new(Allocator.Temp);
unsafe
{
ColliderCastInput input = new()
{
Collider = collider.ValueRO.ColliderPtr,
Orientation = quaternion.identity,
Start = lw.ValueRO.Position,
End = new(0, 0, 10),
};
var isHit = collisionWorld.CastCollider(input, ref hits);
Debug.Log($"{isHit} {hits.Length}");
}
}
}
}