//void OnTriggerEnter(Collider other) //{ // for (int i = 1; i <= 4; i++) // { // if (other.gameObject.tag == "Vacuum" + i.ToString() && other.gameObject.transform.parent.GetComponent<PlayerController>().PlayerVacuum) // { // other.gameObject.GetComponent<BoxCollider>().enabled = false; // scoreOwner = i; // targetLocation = other.gameObject.transform.parent.transform.position; // this.transform.parent.parent.parent.GetComponent<BeltPlateController>().Restock(Random.Range(2f, 8f)); // Vector3 temp = transform.position; // world pos // this.gameObject.transform.SetParent(null , true); // *should* not move, but you say... // // this.transform.position = temp; // restore world position // sucked = true; // // Debug.Log("sucked"); // //destroy // } // } //} void OnTriggerStay(Collider other) { for (int i = 1; i <= 4; i++) { if (other.gameObject.tag == "Vacuum" + i.ToString() && other.gameObject.transform.parent.GetComponent <PlayerController>().PlayerVacuum) { audioManager.playItemHitSound(); other.gameObject.GetComponent <BoxCollider>().enabled = false; scoreOwner = i; targetLocation = other.gameObject.transform.parent.transform.position; if (transform.root != this.transform) { Transform par = this.transform.parent.parent.parent; if (par) { BeltPlateController bpc = par.GetComponent <BeltPlateController>(); if (bpc) { bpc.Restock(Random.Range(respawnMin, respawnMax)); } } Vector3 temp = transform.position; // world pos this.gameObject.transform.SetParent(null, true); // *should* not move. // this.transform.position = temp; // restore world position sucked = true; // Debug.Log("sucked"); //destroy } } } }
public void AddItemToBeltPlate(GameObject _beltPlateObj) { GameObject model = itemManager.GetItemModel(); BeltPlateController bpc = _beltPlateObj.GetComponent <BeltPlateController>(); Vector3 pos = bpc.itemAnchor.position; GameObject.Instantiate(model, pos, Quaternion.identity, bpc.itemAnchor); }
public void CreateBelt() { for (int i = 0; i < BeltCapacity; i++) { Vector3 pos = IndexToPosition(i); GameObject go = GameObject.Instantiate(BeltPlatePrefab, pos, Quaternion.identity, BeltTopTransform); beltPlates.Add(go); BeltPlateController bpc = go.GetComponent <BeltPlateController>(); bpc.beltIndex = i; } }
public void RequestRestock(GameObject _plateChild, float _delay = 0.0f) { BeltPlateController bPlate = _plateChild.GetComponentInParent <BeltPlateController>(); bPlate.Restock(_delay); }