I'm attempting to make a melee script for my player character, I have placed a trigger sphere collider in-front of the player, and was wondering if I could use this collider to get the reference of the gameobject of any enemy that enters the collider, and then use that reference to get the enemy's health script, and call a function on it.
void OnTriggerStay(Collider other)
{
if (other.gameObject.tag.Equals("Enemy"))
enemyGameObject = other.gameObject; // or something like this?
}
If this is possible, could someone please tell me the proper way to do it, or give me advice on a better way to do melee? (im a novice so the simpler the better)
thanks in advance :)
↧