The following script identifies the object I click on and checks the tag on it. Now I am needing to know what I need to add to this to make it find the child game object and turn it off.
Here is the script:
using UnityEngine;
using System.Collections;
public class ChangeWeather : MonoBehaviour
{
public bool active = true;
private Transform child;
void Update ()
{
if(Input.GetMouseButtonDown(0))
{
Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);
RaycastHit hit;
if(Physics.Raycast(ray, out hit))
{
if(hit.collider.tag == "WorldBlocks")
{
if(active == true)
{
foreach(Transform child in hit.transform)
{
child.Active = false;//This part is not working.
}
active = false;
}
if(active == false)
{
foreach(Transform child in hit.transform)
{
// child.Active = false; This part is not working
}
active = true;
}
}
}
}
}
}