Hi
I want to enable "Is Trigger" if the enemies hit each other and disable it if they hit the player. so the player can die.
i think "on collision enter" will do it but i can't handle the scripting stuff
Hi
I want to enable "Is Trigger" if the enemies hit each other and disable it if they hit the player. so the player can die.
i think "on collision enter" will do it but i can't handle the scripting stuff
Tag all the enemies "Enemy" and tag the player as "Player". Then use this script:
function OnCollisionEnter(collision : Collision) {
if(collision.transform.tag == "Enemy" && !transform.collider.isTrigger){
transform.collider.isTrigger = true;
}
}
function OnTriggerEnter(trigCollision : Collider){
if(trigCollision.transform.tag == "Player" && transform.collider.isTrigger){
transform.collider.isTrigger = false;
}
}
I hope this helps. :)
Try using GetComponent to activate and deactivate the properties of a GameObject
Steps:
1 - Create a variable to identify the gameObject may be through the object tag
2 - Create another variable that is looking for a component within the previous variable
3-and enable or disable the property IsTrigger of the component.
Super old thread but I thought I’d point out the Physics Collision Matrix which does exactly what you need here without any scripting