private void OnTriggerEnter(Collider other) { if (other.CompareTag("Fish")) { GameObject.FindGameObjectWithTag("UniqueSoundObject").GetComponent <AudioSource>().PlayOneShot(other.GetComponent <FishSounds>().FishDeathSound); BuildFishTrail.RemoveFish(other.gameObject); } if (other.CompareTag("Ocean") && LifeTime > 0.5f) { InWater = true; } }
void OnTriggerEnter(Collider other) { Debug.Log(other.tag + " Collided"); if (other.CompareTag("Fish")) { if (other.GetComponent <FishType>().myType == myType) { Source.PlayOneShot(other.GetComponent <FishSounds>().FishGetsHomeSound); Debug.Log("Same type"); BuildFishTrail.RemoveFish(other.gameObject); GameObject.FindGameObjectWithTag("GameController").GetComponent <GameController>().Score++; Destroy(this.gameObject, 3f); } } }
private void SpawnFish() { int length = BuildFishTrail.FishList.Count; for (int i = 0; i < length; i++) { BuildFishTrail.RemoveFish(0); } for (int i = 0; i < BuildFishTrail.Trail.Count; i++) { BuildFishTrail.Trail[i] = transform.position; } for (int i = 0; i < 3; i++) { Transform g = Instantiate(FishType[i], transform.position, Quaternion.identity); } }