Quantcast
Channel: Questions in topic: "error message"
Viewing all articles
Browse latest Browse all 2891

Unity: Player take damage from enemy projectile

$
0
0
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(); } }

Viewing all articles
Browse latest Browse all 2891

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>