OK I have my mouse trap set up just like everything else but it’s not working?
static var enemyHit : boolean =false; // toggle for attack mode
static var damageAmount:int; // hold player damage amount
function OnTriggerEnter ( other : Collider ) { // trigger events for collider on foot
if ( other.tag == "enemy" ) // if collider equals enemy object
{
enemyHit = true; // enable attacking
damageAmount = other.GetComponent ( EnemyController ).damageAmount; // take damage to player health
yield WaitForSeconds ( 1 ); // wait a second before checking for another hit
}
else if ( other.tag == "robot" ) // if collider equals enemy object
{
enemyHit = true; // enable attacking
damageAmount = other.GetComponent ( AiPatrol ).damageAmount; // take damage to player health
yield WaitForSeconds ( 1 ); // wait a second before checking for another hit
}
else if ( other.tag == "mouseTrap" ) // if collider equals enemy object
{
enemyHit = true; // enable attacking
damageAmount = other.GetComponent ( MouseTrap ).damageAmount; // take damage to player health
yield WaitForSeconds ( 1 ); // wait a second before checking for another hit
print ("Player was hurt by a Mouse Trap");
}
}
function OnTriggerExit ( other : Collider ) { // check for collider exiting
if ( other.tag == "enemy" ) // if tag enemey exits
{
enemyHit = false; // disable enemy hit ability
}
else if ( other.tag == "robot" ) // if tag enemey exits
{
enemyHit = false; // disable enemy hit ability
}
else if ( other.tag == "mouseTrap" ) // if tag enemey exits
{
enemyHit = false; // disable enemy hit ability
}
}
I figured maybe it might help to see this also
Mouse Trap Script
var mouseTrapSnap : AudioClip; // Assign Mouse Trap Snap Audio
var playerHit : boolean = false; // enable player hit
var damageAmount : int = 25;
function Start () {
animation.wrapMode = WrapMode.Once; // set play animation mode to once
animation [ "snap" ].wrapMode = WrapMode.Once; // set animation to play once
}
function OnTriggerEnter ( other : Collider ) { // if collision with player
//var controller : CharacterController = GetComponent(CharacterController);
if ( other.tag == "Player" )
{
//Play Mouse Trap Snap Sound
audio.PlayClipAtPoint ( mouseTrapSnap, transform.position );
yield WaitForSeconds (0.2);
//Play Mouse Trap Snap Animation
animation.Play ( "snap" );
}
else if ( other.tag == "push" )
{
//Play Mouse Trap Snap Sound
audio.PlayClipAtPoint ( mouseTrapSnap, transform.position );
yield WaitForSeconds (0.2);
//Play Mouse Trap Snap Animation
animation.Play ( "snap" );
//Destroys Character Controller);
//Destroy(controller);
//dissable Collider by Destroying it
Destroy(collider);
}
}
function OnTriggerExit ( other : Collider ) {
//var controller : CharacterController = GetComponent(CharacterController);
if ( other.tag == "Player" )
{
yield WaitForSeconds (0.2);
//Destroys Character Controller);
//Destroy(controller);
//dissable Collider by Destroying it
Destroy(collider);
}
}