Well, thats a weird title. What i am trying to do is identify the object which position matches the gameObjects position that the script is attached to. Hell, that didn't make it better.
Here's my script:
public Vector2 tilePosition;
public float tileYPiece;
void Update()
{
tilePosition = transform.position;
tileYPiece = tilePosition.y + 0.5f;
pieceIdentifier();
}
void pieceIdentifier()
{
if ((tileYPiece) == GameObject.FindGameObjectWithTag("Piece").GetComponent<PieceScript>().piecePosition.y && tilePosition.x == GameObject.FindGameObjectWithTag("Piece").GetComponent<PieceScript>().piecePosition.x)
{
//the GameObject I need to reference does something
}
}
So the tile position is a Vector2(x, y), and the piece's position is a Vector2 (x, y) as well, and I need to reference the GameObject that shares position with the tile.
I'm confused as hell, if you hadn't noticed, and would reeally like some help
Thanks in advance