Question by
HyblockerDevelopment · Sep 18, 2016 at 05:43 PM ·
c#functionsendmessagemethod
Player not activating method
I have a character and a zombie, both in the same layer. The player shoots and the zombie loses health, the zombie attacks but nothing happens.
This is what I've done in the zombie script:
private void Awake()
{
playerObject = GameObject.FindGameObjectWithTag("player");
}
private void ZombieAttack()
{
if(playerObject!=null)
{
playerObject.SendMessageUpwards("ApplyDamage",10f,SendMessageOptions.DontRequireReceiver);
}
}
And in the player script:
private float health =100f;
public ParticleSystem bloodFX;
public void ApplyDamage(float damage)
{
health-=damage;
bloodFX.Emit (60);
}
Comment