void Start() { // Enable fracturable object collider FracturedObject fracturedObject = GetComponent <FracturedObject>(); pv = fracturedObject.GetComponent <PhotonView> (); // Disable chunk colliders k1 = GameObject.Find("k1").GetComponent <Text>(); k2 = GameObject.Find("k2").GetComponent <Text>(); k3 = GameObject.Find("k3").GetComponent <Text>(); k4 = GameObject.Find("k4").GetComponent <Text>(); if (fracturedObject != null) { if (fracturedObject.GetComponent <Collider>() != null) { fracturedObject.GetComponent <Collider>().enabled = true; } else { Debug.LogWarning("Fracturable Object " + gameObject.name + " has a dynamic rigidbody but no collider. Object will not be able to collide."); } for (int i = 0; i < fracturedObject.ListFracturedChunks.Count; i++) { EnableObjectColliders(fracturedObject.ListFracturedChunks[i].gameObject, false); } } }
void OnCollisionEnter(Collision collision) { if (collision.contacts == null) { return; } if (collision.contacts.Length == 0) { return; } // Was it a big enough hit? FracturedObject fracturedObject = gameObject.GetComponent <FracturedObject>(); if (fracturedObject != null) { float fMass = collision.rigidbody != null ? collision.rigidbody.mass : Mathf.Infinity; if (collision.relativeVelocity.magnitude > fracturedObject.EventDetachMinVelocity && fMass > fracturedObject.EventDetachMinVelocity) { // Disable fracturable object collider fracturedObject.GetComponent <Collider>().enabled = false; Rigidbody fracturableRigidbody = fracturedObject.GetComponent <Rigidbody>(); if (fracturableRigidbody != null) { fracturableRigidbody.isKinematic = true; } // Enable chunk colliders for (int i = 0; i < fracturedObject.ListFracturedChunks.Count; i++) { EnableObjectColliders(fracturedObject.ListFracturedChunks[i].gameObject, true); } // Explode fracturedObject.Explode(collision.contacts[0].point, collision.relativeVelocity.magnitude); } } }
void OnCollisionEnter(Collision collision) { if (collision.contacts == null) { return; } if (collision.contacts.Length == 0) { return; } // Was it a big enough hit? FracturedObject fracturedObject = gameObject.GetComponent <FracturedObject>(); if (fracturedObject != null) { float fMass = collision.rigidbody != null ? collision.rigidbody.mass : Mathf.Infinity; //Debug.Log (collision.gameObject.tag.ToString ());충돌체의 tag탐색 //Debug.Log(collision.gameObject.GetComponent<FracturedObject>().EventDetachMinMass.ToString()); if (collision.relativeVelocity.magnitude > fracturedObject.EventDetachMinVelocity && fMass > fracturedObject.EventDetachMinVelocity) { // Disable fracturable object collider if (collision.rigidbody != null) { //SendKill (PhotonNetwork.player.ID); fracturedObject.EventDetachMinMass -= collision.rigidbody.mass; } if (fracturedObject.EventDetachMinMass < 0) { //Debug.Log (collision.gameObject.GetComponent<PhotonView> ().ownerId.ToString ()); //부순사람 카운트 업 SendKill(collision.gameObject.GetComponent <PhotonView> ().ownerId); //부셔진돌 캔버스 제거 //DeleteName1 (fracturedObject,collision); //fracturedObject.transform.Find("Canvas").GetComponent<Canvas>().enabled = false; //Debug.Log (fracturedObject.name); fracturedObject.GetComponent <Collider> ().enabled = false; Rigidbody fracturableRigidbody = fracturedObject.GetComponent <Rigidbody> (); if (fracturableRigidbody != null) { fracturableRigidbody.isKinematic = true; } for (int i = 0; i < fracturedObject.ListFracturedChunks.Count; i++) { EnableObjectColliders(fracturedObject.ListFracturedChunks[i].gameObject, true); } // Explode fracturedObject.Explode(collision.contacts[0].point, collision.relativeVelocity.magnitude); //죽은돌 삭제 GameObject delStone = GameObject.Find(fracturedObject.name); Destroy(delStone); } // Enable chunk colliders } } }
void OnCollisionEnter(Collision collision) { if (collision.gameObject.tag == "Stone") { if (mujuk == false) { mujuk = true; if (collision.contacts == null) { return; } if (collision.contacts.Length == 0) { return; } // Was it a big enough hit? FracturedObject fracturedObject = gameObject.GetComponent <FracturedObject> (); if (fracturedObject != null) { float fMass = collision.rigidbody != null ? collision.rigidbody.mass : Mathf.Infinity; if (collision.relativeVelocity.magnitude > fracturedObject.EventDetachMinVelocity && fMass > fracturedObject.EventDetachMinVelocity) { // Disable fracturable object collider if (collision.rigidbody != null) { fracturedObject.EventDetachMinMass -= collision.rigidbody.mass; } if (fracturedObject.EventDetachMinMass < 0) { //Debug.Log (collision.gameObject.GetComponent<PhotonView> ().ownerId.ToString ()); //부순사람 카운트 업 if (collision.gameObject.GetComponent <PhotonView> ().owner.ID == 1) { SendKill(collision.gameObject.GetComponent <PhotonView> ().owner.ID, k1.text); } if (collision.gameObject.GetComponent <PhotonView> ().owner.ID == 2) { SendKill(collision.gameObject.GetComponent <PhotonView> ().owner.ID, k2.text); } if (collision.gameObject.GetComponent <PhotonView> ().owner.ID == 3) { SendKill(collision.gameObject.GetComponent <PhotonView> ().owner.ID, k3.text); } if (collision.gameObject.GetComponent <PhotonView> ().owner.ID == 4) { SendKill(collision.gameObject.GetComponent <PhotonView> ().owner.ID, k4.text); } //부셔진돌 캔버스 제거 fracturedObject.GetComponent <Collider> ().enabled = false; Rigidbody fracturableRigidbody = fracturedObject.GetComponent <Rigidbody> (); if (fracturableRigidbody != null) { fracturableRigidbody.isKinematic = true; } for (int i = 0; i < fracturedObject.ListFracturedChunks.Count; i++) { EnableObjectColliders(fracturedObject.ListFracturedChunks [i].gameObject, true); } // Explode fracturedObject.Explode(collision.contacts [0].point, collision.relativeVelocity.magnitude); //죽은돌 삭제 GameObject delStone = GameObject.Find(fracturedObject.name); Destroy(delStone); } // Enable chunk colliders } } } StartCoroutine("divine"); } }