Ive tagged my enemy in the tag manager but how can I access it through scripts? I want an IF statement to check if its been hit.
okay, cheers.
Im using a raycast to detect the enemy, and on my gun is the following script. How can I detect the raycasted enemys name, iv got gameObject.tag == “enemy”, but I need something like raycast.gameObject.tag == “enemy”…
Anyone know the correct syntax?
if (Physics.Raycast (transform.position, direction, hit, range)) {
if (hit.rigidbody)
hit.rigidbody.AddForceAtPosition(force * direction, hit.point);
if (gameObject.tag == "enemy"){
hit.transform.gameObject.tag
cheers
Don’t forget, the Script Reference is your friend. It’ll answer common questions like these relatively quickly if use its search bar.