Call function on collided object

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.

Is that the actual code?

GetComponent needs a parameter.

Otherwise, I don’t see why it wouldn’t work.

You haven’t specified which component you want to get from the other object. Also you seem to be mixing-in some C# syntax:

var myScript : MyScript = other.gameObject.GetComponent(MyScript);
myScript.Death();

I thought you needed to do something extra. I’ll try it right away. Thanks for the tips guys!
Making something weird but the sword thing really needs to work :slight_smile:

It works!!! Awesome, thanks!

function OnCollisionEnter(other : Collision) {
	if(other.gameObject.name == "Enemy")  { 
		var myScript : SentaEnemyShooter = other.gameObject.GetComponent(SentaEnemyShooter);
		myScript.Death();
	}

}

Getting there!