Dear all,
I’ve been going crazy on this for about an hour now.
I can’t seem to call a function on the object the player collided on.
Here’s the code (lots of code in comments which didn’t work)
function OnCollisionEnter(other : Collision) {
if(other.gameObject.name == "Enemy") {
//SendMessageUpwards("hitBySlash");
//other.Death();
//Destroy(other.gameObject);
//var enemy: GameObject = other.transform.parent.gameObject;
//var enemy: GameObject = other.transform.root.gameObject;
//var enemy: GameObject = other.collider.gameObject;
//other.Death();
//enemy.BreadcastMessage("Death");
//if (other.GetComponent(SentaEnemyShooter)){other.GetComponent(SentaEnemyShooter).Death();}
MyScript ms = other.collider.GetComponent();
ms.Death();
}
}
Any idea what I’m doing wrong?
The object that has this script cannot become a trigger because it’s an active unit in the game, as is the one that gets hit.