I am creating a basic game for test purpose in unity3D where i will counter the number of objects whenever the collision occurs on the defined object. I have created objects named birds1 upto birds8 While hitting the objects with name birds1, birds2. I am trying to increment the counter, it should increment the value of f by 1, if the hit the bird here the counter increments by random number instead of increment by 1. I have set a value that the counter should not exceed a limit of 8 so it stops at a limit of 8. Below is my code i am posting the code that i am using. Please can anyone help me with this that where is my code running wrong.
public void OnTriggerEnter2D(Collider2D target)
{
if (target.gameObject.name == "bird1" || target.gameObject.name == "bird2" || target.gameObject.name == "bird3" || target.gameObject.name == "bird4" || target.gameObject.name == "bird5" || target.gameObject.name == "bird6" || target.gameObject.name == "bird7" || target.gameObject.name == "bird8" && f < 8)
{
f++;
propPAnel8.SetActive(true);
BirdText.text = "x " + f;
if (f == 8)
{
bound8.isTrigger = true;
}
}
}
if (target.gameObject.tag == "bird")instead of checking for each individual bird name. - ryeMoss