void OnCollisionEnter2D(Collision2D other) { if (other.gameObject.tag == "Obstacles") { Debug.Log("Hit"); Instantiate(breakVFX, transform.position, Quaternion.identity); AudioSource.PlayClipAtPoint(hitSFX, Camera.main.transform.position, vol); breakVFX.Play(); Destroy(gameObject); } if (other.gameObject.tag == "Hound") { WolfScript en = other.gameObject.GetComponent <WolfScript>(); Debug.Log("Enemy Hit"); en.addDamage(1f); Destroy(gameObject); Instantiate(hitVFX, transform.position, Quaternion.identity); hitVFX.Play(); AudioSource.PlayClipAtPoint(hitSFX, Camera.main.transform.position, vol); } if (other.gameObject.tag == "enemy") { enemyhealth en = other.gameObject.GetComponent <enemyhealth>(); Debug.Log("Enemy Hit"); en.addDamage(1f); Instantiate(hitVFX, transform.position, Quaternion.identity); hitVFX.Play(); AudioSource.PlayClipAtPoint(hitSFX, Camera.main.transform.position, vol); Destroy(gameObject); } }
void LoadWolf(int health) { //-3.414, 0, 4 = spawn pos GameObject wolf = Instantiate(prefab, new Vector3(-3.414f, 0, 4), Quaternion.identity); WolfScript wc = wolf.GetComponent <WolfScript>(); wc.Waypoints = Waypoints; wc.health = health; wolf.transform.LookAt(waypoint0.transform); }