Something really messed up..

var heroScr = hero.GetComponent(Hero);

Putting that into my code generates a really messed up error…

NullReferenceException: Object reference not set to an instance of an object
Enemy.___initializer ()

Log in file:  at line: -1599018336

Ka whaat?

What is “hero” set to?

var hero : GameObject

You should move the initialization to the Start() function:

var heroScr : Hero;

function Start() {
	heroScr = hero.GetComponent(Hero);
}

Generally speaking, initialization that doesn’t use constants should be done in Start(). In this case, because you can’t rely on hero being initialized, you run into trouble trying to call GetComponent() on it. Putting the initialization into Start() will delay it until the game actually starts, by which time you will probably have assigned a reference to hero.

just out of curiosity, do this right before heroScr = hero.GetComponent(Hero);

if( !GetComponent(Hero) ) print( "Hero is NULL!" );

Bronxbomber: Hero is NULL

Muriac: I moved it to the start function, and now I get “Unknown Indentifier: heroScr”

If hero is null, that means it needs to be set in the editor by dragging the hero object into this slot in the component’s inspector pane.

Actually as a neat trick, the hero : GameObject variable is unnecessary.

var hero : Hero;

With that code (“heroScr” is no longer necessary), you can drag your hero - any object that contains the Hero component - onto this variable, and skip the need for a GetComponent call.

Now it gives me the same error, but with a new line added:

“enemy…ctor ()”

O_o

You should post the whole script in its current state so we can get a better idea of the context.

Ah, certainly.

var moveDir = 1;
var hp = 1;
var dp = 1;
var texture : Texture2D;
var walk : Texture2D;
var pain : Texture2D;
var hero : Hero;
var animating = true;
var frameIndex = 1;
var lastframe = 4;
var repeatrate = 0.2;
InvokeRepeating ("Animate", 0.1, repeatrate);

function Update () {
	transform.position.z = -5.5;
	renderer.material.mainTexture = texture;
	if (moveDir == 1) {
		transform.position.x -= .01;
	}
	if (moveDir == 2) {
		transform.position.x += .01;
	}
}

function OnCollisionEnter (c : Collision) {
	//We hit the Hero! What to do?
	if (c.gameObject == hero) {
		//If he's above us.. ow! Take damage and send the guy flying!
		//If he's below us.. yay! Hurt him and send him flying!
		if (c.transform.position.y - 0.9 > transform.position.y) {
				texture = pain;
				lastframe = 7;
				frameIndex = 0;
				moveDir = 0;
				hero.transform.position.y -= .2;
				hero.texture = hero.jleftTex;
				hero.grounded = false;
				hero.rigidbody.AddForce (0, 350, 0);
				hp -= hero.dp+1;
		} else {
			if (moveDir == 1) {
				moveDir = 2;
			} else if (moveDir == 2) {
				moveDir = 1;
			}
			hero.hp -= dp;
		}
	}
}

function OnTriggerEnter (other : Collider) {
	if (other.name == "enemyTrigger") {
		if (moveDir == 1) {
			moveDir = 2;
		} else if (moveDir == 2) {
			moveDir = 1;
		}
	}
}

function Animate () {
	frameIndex += 1;
	
	if (frameIndex == lastframe){
		if (texture == pain) {
			texture = walk;
			frameIndex = 0;
			moveDir = 1;
			lastframe = 4;
		} else {
			frameIndex = 0;
		}
	}
	
    texture.frame = frameIndex;
}

Unity has a bug where it doesn’t clear references if you change their types. Try dragging your GameObject with the Hero script attached to the Hero field in the inspector.

Also, while you’ve changed the type of hero to Hero, you’re still comparing it to a GameObject in your OnCollisionEnter(). This will always return false. Use

if (c.gameObject == hero.gameObject) {

instead.

Thanks for all the help! I got it working now.