2D Tutorial – “Enemy is a Type which is not valid in the given context”

Updated on June 17, 2018 in [A] Tutorials
Share on Facebook0Tweet about this on TwitterShare on Google+0Share on Reddit0
0 on June 17, 2018

Hi guys,

Been following along the old 2D platformer video and I ran into this issue that I can’t seem to find an answer for online. 

Enemy enemy = hit.collider.GetComponent<Enemy>();

if (Enemy != null)
{
enemy.DamageEnemy(Damage);
Debug.Log(“We hit ” + hit.collider.name + ” and did ” + Damage + ” damage.”);
}

I keep getting an error saying “Enemy is a Type which is not valid in the given context”.

 

Any help would be appreciated.

  • Liked by
Reply