Check if 3 same colliders on a line?

134610-capture.png

Hello, can someone tell me if its possible to check when the blue line connecting these 3 figures (instantiated clones of a prefab) is indeed containing 3 same colored figures? I was thinking of colliders but again i have a problem how to know if there are 3 Figure colliders on one connecting line. Thank you!

So if I understand correctly you just want to check if those three prefabs have the same color in line?
If yes then you can try:
public Transform firstPrefab;
public Transform secondPrefab;
public Transform thirdPrefab;

private void CheckIfSameColor(){
    if(firstPrefab.GetComponent<Material>().color == secondPrefab.GetComponent<Material>().color && firstPrefab.GetComponent<Material>().color == thirdPrefab.GetComponent<Material>().color){
         //we got a match
    }
}

its not the pretties and if you have way more prefabs on the screen it would be way better to store prefab’s materials and operate on them. If only possibility to success is to have all three of them at same color then checking first with second and first with third is enough.

Whether it’s on a line Judge two objects x,y Whether it’s the same or not
Or if the Angle between the vectors is 0

I tried that, works as expected with slight modifications, but found another solution since i needed the boolean going false after end of players turn, i used lists to see if the count is equal to 3 figures, and after the turn just cleared the list. Gonna post the code here if anyone else needs it. Thanks for the input anyway! Much love!

public List<Collider> collidedObjectsP1 = new List<Collider>();
public List<Collider> collidedObjectsP2 = new List<Collider>();
public int numberP1;
public int numberP2;
#endregion

#region Update
private void Update()
{
    CheckPhases();
    numberP1 = collidedObjectsP1.Count;
    numberP2 = collidedObjectsP2.Count;

    if (Input.GetKeyDown(KeyCode.S))
    {
        Debug.Log(numberP1);
        Debug.Log(numberP1);
    }
}
#endregion

#region On Trigger Enter
//On trigger enter add the players figure to the list
private void OnTriggerEnter(Collider other)
{
    if((other.gameObject.tag == "Player1Figure") )
    {
        collidedObjectsP1.Add(other);
    }

    if ((other.gameObject.tag == "Player2Figure"))
    {
        collidedObjectsP2.Add(other);
    }
}
#endregion

#region On Trigger Exit
private void OnTriggerExit(Collider other)
{
    collidedObjectsP1.Remove(other);
    collidedObjectsP2.Remove(other);
}
#endregion