FPS Health Pack to CAUSE damage

So I’ve been working in Unity 1.6.2 and am trying to make a variation of the Health Pack script that deals damage. So the FPS walker runs into it and takes X damage.

The following is what I am using - changed the top Healthpack part basically, nothing else. I am clueless at coding so I am not sure what I can change and what i can/can’t delete.

Anyway when I implement this, I get the “All scripts need to successfully compile first!” error and do not understand what I need to change. Any help would be great!

enum PickupType { Health = 0, Rocket = 1 }
var pickupType = PickupType.Health;
var amount = 20;
var sound : AudioClip;

private var used = false;

function ApplyPickup (player : FPSPlayer)
{
	if (pickupType == PickupType.Health)
	{
		if (player.hitPoints <= player.maximumHitPoints)
			return true;
		
		player.hitPoints -= amount;
		player.hitPoints = Mathf.Min(player.hitPoints, player.maximumHitPoints);
	}
	else if (pickupType == PickupType.Rocket)
	{
		var launcher : RocketLauncher = player.GetComponentInChildren(RocketLauncher);
		if (launcher)
			launcher.ammoCount += amount;
	}
	
	return true;
}

function OnTriggerEnter (col : Collider) {
	var player : FPSPlayer = col.GetComponent(FPSPlayer);
	
	//* Make sure we are running into a player
	//* prevent picking up the trigger twice, because destruction
	//  might be delayed until the animation has finnished
	if (used || player == null)
		return;
	
	if (!ApplyPickup (player))
		return;
	used = true;
	
	// Play sound
	if (sound)
		AudioSource.PlayClipAtPoint(sound, transform.position);
	
	// If there is an animation attached.
	// Play it.
	if (animation  animation.clip)
	{
		animation.Play();
		Destroy(gameObject, animation.clip.length);
	}
	else
	{
		Destroy(gameObject);
	}
}

// Auto setup the pickup
function Reset ()
{
	if (collider == null)	
		gameObject.AddComponent(BoxCollider);
	collider.isTrigger = true;
}

Without reviewing your code yet…

The error message should be much better than that. I know a common assumption that noobs make is that the single line error at the bottom of Unity Editor is the error that needs addressed first.

Actually that’s the last error that needs to be addressed. To see ALL the errors double click that error message and the Unity Console pops up.

Work you error messages from the top down. As you fix the top one the others almost always disappear because they were children of the top error.

Also when you double click the error message in the console Unity should open Unitron and place you on the line of the error.

Another great console for error messages - especially after a crash is the console.app - this is built into the OS and to run it just go to Spotlight and type console. This is where you’ll do your nastier debugging and any print statements that you put in you code will show up here also - to help you debug.

Hope this helps – post the top error message and I’m sure someone will respond.

Cheers,

What tom said. Other than that, does just using the existing health pack script and setting the heal amount to negative something work?