Hey ! I am trying to use Colliders in unity. Collisions with projectiles works perfectly for every hitbox so I assume that my Colliders are well-done. However, when the player is at the center of the map, for an unknown reason, he takes damages from enemies far away. It happens when the player is at (or almost) at the center of the map (0,0) and I don't understna why. At first, I used:
int count = rb.Cast(new Vector2(0,0), filter, new RaycastHit2D[10]);
But it caused the bug.
Then ChatGPT suggested
Collider2D hit = Physics2D.OverlapArea(
enemyCollider.bounds.min,
enemyCollider.bounds.max,
GameManager.instance.layerMaskList.characterProjectileLayerMask
);
``` For a square box collider. But the bug is still there with this version.
Then I tried to detect directly with
```csharp
int count = GetComponent<Rigidbody2D>().Cast(movement, filter, hits, 0);
``` But it detetcted "phantom collisions" as well
The only collision detection I found wasn't making any bug was with a static Physics2D.BoundCircle(transform.position, radius)
But this option is painfull to use for complex shapes, as it doesn't use the enemyCollider. So it isn't dynamic.
When I begin to use my enemyCollider, it seems to create the same bug.
Claude suggested to disable Queries Hit Trigger but it didn't work.
It also said that it was probably from unity itself. Is it possible ? Or is it just a simple thing that I don't understand in how unity works?
Help would highly be apppreciated 🙏