Hi all, I hate to be a bother, but I’m stuck. In a nutshell: I have a prefab cannonball that is instantiated and shot at multiple targets passing in front of a cannon when the player fires. Each target has a different tag name for gameplay reasons.
I can’t figure out how to write the script (js) so that the cannonball will explode only when it hits a gameobject collider with one of the appropriate tag names.
The script below works fine, but I’m limited to only one tag name, and I know there is a better way than putting a script for each tag on one prefab cannonball, I’m just too new at scripting to know what it is. I have searched answers, and have found solutions regarding arrays and/or variables, but none address tags specifically, and the required syntax is beyond me.
function OnCollisionEnter(myTarget : Collision) {
if(myTarget.gameObject.tag == "Orc") {
Kaboom();
}
}
Thanks for any/all assistance.
P.S. Compared to most of you guys, I’m ancient and probably old enough to be your grandfather, so please be gentle