I am trying to check if an entity is touching the collider of another entity but this code I wrote is saying the collider is touching the ground but the entity is on the air. am I doing anything obviously wrong?
[UpdateInGroup(typeof(FixedStepSimulationSystemGroup))]
[UpdateBefore(typeof(PhysicsSystemGroup))]
[BurstCompile]
public partial struct HitboxSystem : ISystem
{
[BurstCompile]
public void OnCreate(ref SystemState state)
{
state.RequireForUpdate<HitboxTag>();
}
[BurstCompile]
public unsafe void OnUpdate(ref SystemState state)
{
var physics = SystemAPI.GetSingleton<PhysicsWorldSingleton>();
var collisionWorld = physics.CollisionWorld;
// the docs said I need to do this
state.CompleteDependency();
foreach (var (collider, entity) in SystemAPI.Query<PhysicsCollider>().WithAll<HitboxTag>().WithEntityAccess())
{
var colliderCastInput = new ColliderCastInput
{
Collider = (Unity.Physics.Collider*)collider.Value.GetUnsafePtr(),
Orientation = quaternion.identity,
};
if (collisionWorld.CastCollider(colliderCastInput, out var hit))
{
Debug.Log($"hit: {hit.Entity}");
}
}
}
}
so many different ways to do stuff