Here is a snippet of the code I have and this code is for making the player take damage when a projectile hits him but when I enter the code I get an error saying: error CS0246: The type or namespace name 'Player' could not be found (are you missing a using directive or an assembly reference?)
I have given the player object the Player tag and I have also named the object Player but nothing seems to be working.
Does anyone know how to fix this? I believe it should be an easy fix but I guess I am too big of a noob haha.
void OnTriggerEnter2D(Collider2D hitInfo) {
if(hitInfo.CompareTag("Player"))
{
Player player = GameObject.FindGameObjectWithTag("Player");
player.TakeDamage(20);
DestroyProjectile();
}
}
↧