I have a bullet prefab in 2D unity and I want to drag a gameObject into a public variable so I can deal damage but it won't work. Here is my code, the gameObject I want to drag in is called EnemyAI and there is a script called EnemyAI.
public EnemyAI EnemyHealth;
void OnCollisionEnter2D(Collision2D coll)
{
print("Collided");
if (coll.gameObject.tag == "Wall") //Change tag
Destroy(gameObject);
if (coll.gameObject.tag == "Enemy") //Change tag
Destroy(gameObject);
EnemyHealth.TakeDamage(10);
}
I wanted it to be able to drag the game object in but it didn't let me. I have done this exact same thing before but where the enemy hurts the player, please help.