Finding diagonal objects of an object in 3d space

Posted by samfisher on Game Development See other posts from Game Development or by samfisher
Published on 2014-03-13T10:01:50Z Indexed on 2014/06/11 21:43 UTC
Read the original article Hit count: 245

Filed under:
|
|
|

Using Unity3d, I have a array which is having 8 GameObjects in grid and one object (which is already known) is in center like this where K is already known object. All objects are equidistant from their adjacent objects (even with the diagonal objects) which means

(distance between 4 & K) == (distance between K & 3) = (distance between 2 & K)

1 2 3
4 K 5
6 7 8

I want to remove 1,3,6,8 from array (the diagonal objects).
How can I check that at runtime?

my problem is the order of objects {1-8} is not known so I need to check each object's position with K to see if it is a diagonal object or not. so what check should I put with the GameObjects (K and others) to verify if this object is in diagonal position

Regards,
Sam

© Game Development or respective owner

Related posts about unity

Related posts about cocos2d