When i drag around a tile i want to highlight a field once the ray shot by the card hits a field or another card. That works so far.
Now when the Raycast is not hitting this field or card anymore, i want to disable it.
if(Physics.Raycast(ray, out hit, 15))
{
if(hit.collider.tag == "SnapField")
{
hitPlayfield = true;
hitCard = false;
//highlight the field
HighLightField = hit.collider.transform.FindChild("HighLightField").gameObject;
HighLightField.SetActive(true);
newPosition = hit.collider.gameObject.transform.position;
}
else if(hit.collider.tag == "card")
{
hitPlayfield = false;
hitCard = true;
//Highlight the field
HighLightField = hit.collider.transform.FindChild("HighLightField").gameObject;
HighLightField.SetActive(true);
newPosition = hit.collider.gameObject.transform.position;
DT = hit.collider.gameObject.GetComponent<DragingTiles>();
}
}
else
{
hitPlayfield = false;
hitCard = false;
}
Where and how can i disable that HighlightField GameObject?