Quantcast
Channel: Questions in topic: "melee"
Viewing all articles
Browse latest Browse all 201

Get a game object's reference from collision?

$
0
0
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 :)

Viewing all articles
Browse latest Browse all 201

Trending Articles



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