I need some help with this GetCompnent peice of code:
if(hit.GameObject.tag == "Head")
Enemy.GetComponent(dead) = true;
I am afraid that I don’t know anything about GetCompnent, and after a long time trying to figure this puzzle out, I have not gotten anywhere.
This is my own script. It uses raycast as bullets, and hit is the variable used in the raycast function.
GetComponent() gets access to a script instance attached to a game object. So in theory, you are getting access to the ‘dead’ script. But there are a couple of things that don’t make sense to me with this code. Usually you would see something like:
enemy.GetComponent(Enemy).dead = true;
Plus it is difficult to see how the head hit maps to a specific enemy. Is this a script you got somewhere? Can you post the rest of the code?