Stationary Raycast Hitbox / Pairing Problem

I am using a client-side stationary hitbox (don’t worry, sanity checks are there) that uses attatchments, with one in each corner. Raycasts are fired from each attatchment to every other one and will tell the server if anything intersects. I need this specifically since: raycasts are cheap, results can be quick, and they don’t need to be moving.

The issue with this system is that there will be useless “double checks”. Since each attatchment fires at every other one, the loop will eventually repeat a pair of attatchments. For example:

There are three points: 1, 2, and 3.
Point 1 fires to point 2, then to point 3.
Point 2 now fires to 3, but fires to point 1 which is reduntant.

Is there a way to list pairs, detect them, and prevent them from firing to save resources?

Why are you doing this, what are you trying to check for?

As I stated, I am doing this because:

  • Raycasts are cheap and effective
  • These can return instantly
  • Doesn’t need to be a box specifically, could be a cone or anything else.
  • No movement required like that one raycast module.
  • Easy to scale.

These are planned to detect hit enemies, but could really be used for just about anything as long as the target isn’t too small.

This will only detect if something is both intersecting an edge, and is not completely enclosing the origin the ray was cast from. That is very specific, and not a check for collision in general. What is your specific use case?

It’s for melee strikes, like swinging a knife or sword. The targets aren’t gargantuan or anything, and if I need something really large/small I could use magnitude.


This is what it looks like when visualized. This is also a relatively large hitbox as well, and I plan to use something around half the size.

You should use the Separating Axis Theorem for this kind of box check: