How to check if 3 objects are next to each other.

So I’m designing a puzzle game similar to bejeweled. If 3 identical objects are next to each other, they are destroyed. What would be a good way to determine if 3 or more objects are next to each other? Should I have a script with a linecast method in it on every block? Can someone help me with some logic?

It would vastly simplify everything if you just use an array to represent the game board. Then you can simply look at adjacent elements in the array. Don’t bother with raycasting or anything like that. The game objects would be positioned based on the contents of the array (and it makes things even easier if you scale the objects so each one fits in 1 unit, so you have a 1:1 relationship between the array and 3D space, though that’s not strictly necessary). See here for an old example of Tetris, done with an array. (One of the earliest things I did with Unity actually… Though a Bejeweled-type game would be simpler, since you’d only ever have one object per array entry, whereas Tetris requires management of groups.)