Quantcast
Channel: Questions in topic: "enemy"
Viewing all articles
Browse latest Browse all 1488

Hit enemy life with raycast

$
0
0
This is part of the code of my bullet that take enemy life, but it gives me an error: Type `UnityEngine.Component' does not contain a definition for `health' and no extension method `health' of type `UnityEngine.Component' could be found (are you missing a using directive or an assembly reference?) Script: if(Physics.Raycast(rayAim, out hit, range)){ if(hit.collider.gameObject.tag == "Enemy") { hit.collider.GetComponent("EnemyScript").health --; } } (I have no variable on bullet script, but i have health variable on enemyscript)

Viewing all articles
Browse latest Browse all 1488

Trending Articles



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