void OnCollisionEnter(Collision c) { if (flying) { //Debug.Log("collision"); if (c.collider.CompareTag("Ground")) { flying = false; //m_rigidBody.useGravity = false; //m_rigidBody.velocity = Vector3.zero; //m_rigidBody.angularVelocity = Vector3.zero; transform.position = c.contacts[0].point; GameObject anchor = new GameObject("ANCHOR"); anchor.transform.position = transform.position; anchor.transform.rotation = transform.rotation; anchor.transform.SetParent(c.transform); this.anchor = anchor.transform; m_rigidBody.freezeRotation = true; Destroy(m_rigidBody); GetComponent <Collider>().isTrigger = true; // attach to ground //transform.SetParent(c.collider.transform); //Destroy(gameObject); StartCoroutine(WaitAndDestroy()); } else if (c.collider.CompareTag("PlayerAttack") && !falling) { // get blocked falling = true; GameObject h = hitEffectPoolManager.getBlockArrowHitEfects(); //h.SetActive(true); h.transform.position = c.contacts[0].point; h.GetComponent <ParticleSystem>().Play(); h.GetComponent <AudioSource>().Play(); m_rigidBody.velocity = -0.1f * m_rigidBody.velocity; } } }
void OnTriggerEnter(Collider c) { if (c.CompareTag("PlayerAttack")) { // get blocked Debug.Log("Spear get blocked"); GetComponent <Collider>().enabled = false; // generate hit effect GameObject h = hitEffectPoolManager.getBlockArrowHitEfects(); h.transform.position = transform.position; h.GetComponent <ParticleSystem>().Play(); h.GetComponent <AudioSource>().Play(); // affect enemy (parent holder) animator m_enemyAnimator.executeGetBlocked(); } }