Question by
szabiszekely001 · Nov 01, 2021 at 12:09 PM ·
gameobject
Disable another object in a script
So I made an enemy in my game and I try to disable two objects at the same time to make it dead but for some reason I got errors so I went online to find answers and I found this answer to my problem
GameObject.Find("other_object_name").GetComponent(B).enabled = false;
I tried out in my code and didn't worked. it said "EnemyGFX' is a type, which is not valid in the given context" and I don't know what the heck to to with this so if anyone know an answer to this pls reply an also here is the context that I used in
void Die()
{
Debug.Log("Enemy died");
animator.SetBool("IsDead", true);
GameObject.Find("Bird")
.GetComponent(EnemyGFX).enabled = false;
GetComponent<Collider2D>().enabled = false;
this.enabled = false;
}
Comment