It's a 2d kind of game. We don't take Y axis into consideration.
let's say we have white square points
that could be generated/ move anywhere (the point is they are not fixed in place).
now, we also have other Transforms going around.
the point is we need to determine which of those Transforms are on one side of the "barrier"
and which ones are on the other side of the barrier.
by barrier we mean a line that could be drawn from one white square here to another (and extended after them, ad infinitum - as shown in the picture).
the point is,I didn't find a solution for such a problem yet.
do you have any ideas?
How to detect which ones are on one side and which ones on the other?
(here- color-coded how it would look like after solution) :
A positive value indicates point B lies to the right of line AC, looking from A to C.
A negative value indicates point B lies to the left of line AC, looking from A to C.
For your use, you input (x, z) instead of (x, y). Doesn't matter which plane you use.
Using your example:
Vector3 barrierA = barrierATransform.position;
Vector3 barrierB = barrierBTransform.position;
Vector3 redThing = redThingTransform.position;
if (GetSignedAreaX2(barrierA.x, barrierA.z,
redThing.x, readThing.z
, barrierB.x, barrierB.z) > 0)
{
// Red thing is to the right of the barrier.
}
Of course, you could adapt the nomenclature to whatever fits your need.
For more information on it: Softsurfer and Wolfram. (Search for "signed".)