private void OnTriggerEnter2D(Collider2D collision) { if (collision.CompareTag("zombie_kopf")) { z_zl = GameObject.FindObjectOfType(typeof(Zombie_Leben)) as Zombie_Leben; z_zl.addDamage(10); Instantiate(z_zombie_blut, b_zombie_blut_pos.transform.position, transform.rotation); cm.z_zombie_getroffen(); // print("Zombie getroffen"); } }
private void Update() { RaycastHit2D hitInfo = Physics2D.Raycast(transform.position, transform.up, distance, whatIsSolid); if (hitInfo.collider != null) { if (hitInfo.collider.CompareTag("zombie_bauch")) { z_zombie_leben = GameObject.FindObjectOfType(typeof(Zombie_Leben)) as Zombie_Leben; z_zombie_leben.addDamage(damage_zombie_bauch); //hitInfo.collider.GetComponent<Zombie_Leben>().addDamage(damage); } DestroyProjectile(); } if (hitInfo.collider != null) { if (hitInfo.collider.CompareTag("zombie_hand")) { z_zombie_leben = GameObject.FindObjectOfType(typeof(Zombie_Leben)) as Zombie_Leben; z_zombie_leben.addDamage(damage_hand); //hitInfo.collider.GetComponent<Zombie_Leben>().addDamage(damage); } DestroyProjectile(); } if (hitInfo.collider != null) { if (hitInfo.collider.CompareTag("zombie_kopf")) { z_zombie_leben = GameObject.FindObjectOfType(typeof(Zombie_Leben)) as Zombie_Leben; z_zombie_leben.addDamage(damage_zombie_kopf); //hitInfo.collider.GetComponent<Zombie_Leben>().addDamage(damage); } DestroyProjectile(); } if (hitInfo.collider != null) { if (hitInfo.collider.CompareTag("zombie_boss_kopf")) { z_zombie_boss_leben = GameObject.FindObjectOfType(typeof(Zombie_Boss_Leben)) as Zombie_Boss_Leben; z_zombie_boss_leben.addDamage(damage_zombie_kopf); //hitInfo.collider.GetComponent<Zombie_Leben>().addDamage(damage); } DestroyProjectile(); } // transform.Translate(Vector2.up * speed * Time.deltaTime); }