Question by
MaartenS11 · Mar 31, 2016 at 11:52 AM ·
javascript-specific
hit gameobject tag
I use a raycast in my gun script and if it hits a gameobject with the tagg zombie it has to send a message to that gameobject to apply damage I can send messages and detect if somthing is hit but it doesn't recognise the tag. here is my code to detect the hit:
if (Physics.Raycast(transform.position, fwd, 10)&& tag == Zomie) {
print("hit");
gameObject.Find("Zomie").SendMessage("ApplyDamage");
}
Comment
Answer by meat5000 · Mar 31, 2016 at 11:59 AM
Tags are Strings.
tag == "Zombie"
Tags must be defined in the Tag manager.