I have tried to modify the code that I downloaded from the asset store to only react to a specific tag, such as box. The would collider would serve as a button to open a door by playing an animation. I have tried a few different ways to tweak the code so it will work with a specific tag, but I know very, very little about how to code. Only the “button” part doesn’t work, the script works just fine otherwise. It is in “javascript”.
Can someone explain, or send me a link to a tutorial? I would very much appreciate it. This is the ‘base’ code, one i did not edit.
#pragma strict
function OnTriggerEnter (obj : Collider) {
var thedoor = gameObject.FindWithTag(“SF_Door”);
thedoor.GetComponent.().Play(“open”);
}
function OnTriggerExit (obj : Collider) {
var thedoor = gameObject.FindWithTag(“SF_Door”);
thedoor.GetComponent.().Play(“close”);
}