Hello, I am currently creating a small game in unity for a school project, and I have a small question for an error that's occured.
I have created a soldier, and I want him to have a knife, so he can stab his enemies. to do this, I created an invisible collider infront of him, which follows him around. On this collider, I added this code:
function OnTriggerEnter(obj:Collider)
{
if(Input.GetKeyDown("E"))
{
print(123123);
if(obj.gameObject.tag == "Enemy")
{
//Enemy.Life = 0;
print("TAGGED");
}
}
}
As you see, there's a print to write out if I collide with the enemy (yes, I have an object on the scene both named and tagged as "Enemy") But when I collide with it and hit the button E, nothing appears. I wonder if anyone of you might know the solution to this. Thanks in advance. :)