In addition to the enemy dying due to hits from Lerpz, I want to create another condition in which if a variable meets a specific state requirement, the function (Die) takes place. However, this isn’t working. The second problem is that I don’t know the controls to have Lerpz punch! Every key and mouse button I’ve tried doesn’t seem to work. I have also made sure that the ThirdPersonAttack script is added onto the player.
var rand : Pickup;
var exchange : Pickup;
var hitPoints = 3;
var explosionPrefab : Transform;
var deadModelPrefab : Transform;
var healthPrefab : DroppableMover;
var fuelPrefab : DroppableMover;
var dropMin = 0;
var dropMax = 0;
// sound clips:
var struckSound : AudioClip;
private var dead = false;
function ApplyDamage (damage : int)
{
// we’ve been hit, so play the ‘struck’ sound. This should be a metallic ‘clang’.
if (audio struckSound)
audio.PlayOneShot(struckSound);
if (hitPoints <= 0)
return;
hitPoints -= damage;
if (!dead hitPoints <= 0)
{
Die();
dead = true;
}
if (exchange == 0 rand == 0)
{
Die();
dead = true;
}
}
function Die ()
{
// Kill ourselves
Destroy(gameObject);