Search Unity

Zombie Damage and Hit Animation.

Discussion in 'Animation' started by waqas_90, Jun 7, 2017.

  1. waqas_90

    waqas_90

    Joined:
    Dec 5, 2016
    Posts:
    2
    Hi all developers. I am facing a problem with animation. I want to play an animation when the zombie get 'hit', it should play his 'hit' animation. Here is the code, any help will be greatly appreciated.

    using UnityEngine;
    using System.Collections;

    [RequireComponent(typeof(CapsuleCollider))]
    [RequireComponent(typeof(ZombieStatus))]

    public class Hit_Body : AS_BulletHiter
    {

    public int Suffix = 0;

    public ZombieStatus damageManage;
    public AnimationClip zombiehit;

    public static bool zombie = false;



    void Start(){
    if(damageManage == null){
    damageManage = this.RootObject.GetComponent<ZombieStatus> ();



    }
    }



    public override void OnHit (RaycastHit hit, AS_Bullet bullet)
    {

    if (this.gameObject.tag == "Enemy")
    {

    if (zombie = true)

    this.RootObject.GetComponent<ZombieStatus>().ApplyDamage(50, bullet.transform.forward * Random.Range(50, 150), Random.Range(0, 2));

    zom.GetComponent<AnimationClip>()[zombiehit.name].WrapMode = WrapMode.Loop;



    Debug.Log("ye hit body wala code se body ko hit kia gya hai");
    //Score.score += scoreValue;

    }
    else if(this.gameObject.tag=="head")
    {

    this.RootObject.GetComponent<ZombieStatus>().Dead(0);
    Debug.Log("i hit the head");

    }
    //}
    AddAudio (hit.point);
    base.OnHit (hit, bullet);
    }
    }