Here belows is the code is use to make a mousetrap snap when I walk again it. the problem is that when I have multiple mousetraps in my scene to make that only the mousetrap i collide with hits and not the other once. I applied the code to my character (the person). Any idea what I need to change in this?
lesfundi
var TrapClosed : boolean = false;
function OnControllerColliderHit(hit:ControllerColliderHit){
if((hit.gameObject.tag == "mousetrap") (TrapClosed == false)){
closeTrap();
}
}
function closeTrap(){
var theTrap = gameObject.FindWithTag("mousetrap");
theTrap.animation.Play("snapping");
TrapsClosed = true;
}
i tried this instead but still no luck. Any help out there?
var TrapClosed : boolean = false;
function OnControllerColliderHit(hit:ControllerColliderHit){
if((hit.gameObject.tag == "mousetrap") (TrapClosed == false)){
var theTrap = ControllerColliderHit.gameObject;
theTrap.animation.Play("snapping");
TrapsClosed = true;
}
}
Well, that’s because the controller Collider hit calls the function for any collider, so My suggestion is to use the Object’s ID you are colliding and contrast it with the Hit.transform.gameObject’s ID.
could be that your traps are pretty close and the character touches 2 traps… so separate the traps more 
hope this helps you 
could you maybe show how to write that in the coding?
sorry to take your time.
lesfundi
The second script is probably mostly OK, but on the last line, you’ve typed “TrapsClosed” while the variable is actually declared as TrapClosed (without the extra ‘s’).