Question by
Zersya · Mar 24, 2016 at 11:13 AM ·
booleandrag-and-drop
Get the boolean from the child to the parents
hai,
i want to create drag & drop system, 
and i want if every child (Barang) is true, the Parent (Winner) recieve boolean true

this is the "Slot_Recieve" script
public string namabar;
public bool barang = false;
void Update()
{
if (transform.childCount > 0)
{
barang = transform.FindChild(namabar);
if (barang)
{
Debug.Log("Benar");
barang = true;
// Debug.Break();
}
else
{
Debug.Log("Salah");
barang = false;
//Debug.Break();
}
}
}
and this is the "TrueAll" Script
public bool Winner;
void Start()
{
Winner = gameObject.GetComponentInChildren<Slot_Recieve>().barang;
}
void Update()
{
if (Winner)
{
Winner = true;
Debug.Log("win");
}
}
the problem is, when the all child is true, the parent does not true. please help me out this problem..
thank you
screenshot-20160324175533.png
(141.8 kB)
screenshot-20160324175905.png
(172.9 kB)
Comment
Your answer