I have been working on the following script to allow me to click on a grid in my game and check the tag of it, If it has the tag world blocks it does something to only that block. What I am trying to do now it make it so when you click on a block it turns on or off the particlesystem that is childed to it. I have the particle childed to the block. I am not sure how to make it so when you click it checks if it is on or off and and switches the state of it.
This is my updated script I have so far it is getting close to what I need just cant get all fixed.
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;
}
}
}
}
}
}