public void death() { try { Spawner spawner = GameObject.FindGameObjectWithTag("spawner").GetComponent <Spawner>(); CameraFuncs camfuncs = GameObject.FindGameObjectWithTag("MainCamera").GetComponent <CameraFuncs>(); if (spawner != null && camfuncs != null && spawner.getCurArray().Count == 1 && (object)spawner.getCurArray()[spawner.getCurArray().Count - 1] == gameObject) { camfuncs.startSlowMo(); } } catch { } rig.velocity = new Vector2(0, rig.velocity.y); rig.gravityScale = 5f; transform.rotation = Quaternion.Euler(new Vector3(0, 0, 0)); rig.constraints = RigidbodyConstraints2D.FreezeRotation; animator.SetBool("Death", true); }
void death() { try { Spawner spawner = GameObject.FindGameObjectWithTag("spawner").GetComponent <Spawner>(); CameraFuncs camfuncs = GameObject.FindGameObjectWithTag("MainCamera").GetComponent <CameraFuncs>(); if (spawner != null && camfuncs != null && spawner.getCurArray().Count == 1 && (object)spawner.getCurArray()[spawner.getCurArray().Count - 1] == gameObject) { camfuncs.startSlowMo(); } } catch { } state = 3; animator.SetBool("Death", true); GameObject parts = Instantiate(skeletonParts, transform.position, Quaternion.identity); parts.GetComponent <Rigidbody2D>().velocity = GetComponent <Rigidbody2D>().velocity; StartCoroutine(waitDestroy()); }
/* * Function that is executed when enemy dies. */ void deathBump() { try { Spawner spawner = GameObject.FindGameObjectWithTag("spawner").GetComponent <Spawner>(); CameraFuncs camfuncs = GameObject.FindGameObjectWithTag("MainCamera").GetComponent <CameraFuncs>(); if (spawner != null && camfuncs != null && spawner.getCurArray().Count == 1 && (object)spawner.getCurArray()[spawner.getCurArray().Count - 1] == gameObject) { camfuncs.startSlowMo(); } } catch { } state = 2; rig.gravityScale = 3; animator.SetBool("Death", true); //GetComponent<Collider2D>().isTrigger = false; rig.velocity = new Vector2(rig.velocity.x, 25); rig.constraints = RigidbodyConstraints2D.None; StartCoroutine(destroyOverTime()); }
public void death() { Spawner spawner = null; try { spawner = GameObject.FindGameObjectWithTag("spawner").GetComponent <Spawner>(); } catch {} CameraFuncs camfuncs = GameObject.FindGameObjectWithTag("MainCamera").GetComponent <CameraFuncs>(); if (spawner != null && camfuncs != null && spawner.getCurArray().Count == 1 && (object)spawner.getCurArray()[spawner.getCurArray().Count - 1] == gameObject) { camfuncs.startSlowMo(); } if (!animator.GetBool("Death")) { animator.SetBool("Death", true); rig.constraints = RigidbodyConstraints2D.None; rig.velocity = new Vector2(rig.velocity.x * 3, rig.velocity.y + 30); StartCoroutine(destroyOnTime()); } }