There will be specific things required for them to destroy one another, but for the moment, how do I make it so that Samurai will destroy the Ninja whenever they collide? What coding would be necessary to add to the RidgedBodyFPSWalker script to make sure this happened?
function OnCollisionStay(hit : Collision) {
if (hit.gameObject.tag=="Samurai") {
Destroy(gameObject);
}
}
that's my code as it currently stands for the purposes of making it so the ninja kills the samurai. But as far as I can tell, it doesn't RECOGNIZE the collission when it happens. I'm ripping my hair out over this, please help?
function OnTriggerEnter (other : Collider) {
var hit : RaycastHit;
if (Physics.Raycast (transform.position, new Vector3(0,1,0), hit, 510)){
if (hit.collider.gameObject.tag("light")) {
Destroy(gameObject);
}
}
}
That's the code I've used for one of my guys. If he's under a certain type of tile above him, then he is destroyed when he runs into the trigger field collider object I've set up around the other player. The cieling tiles are all marked as either light or shadow. If the ninja is under a tile marked "light" when he runs into the field, he dies, if the samurai is under a "shadow" marked tile, when they run into each other, he dies. The only difference in the code is the tag that's supposed to be registered when they run into each other. I keep getting a weird error message though when they DO run into each other