using System.Collections; using System.Collections.Generic; using UnityEngine; public class HumanFight : MonoBehaviour { public GameObject goHuman; Animator aniHuman; public int HitCount = 0; public float fSpeed = 2.0f; Transform tr; // Use this for initialization void Start () { aniHuman = goHuman.GetComponent(); tr = transform; } // Update is called once per frame void Update () { aniHuman.SetInteger("HitCount", HitCount); tr.position += tr.forward * fSpeed * Time.deltaTime; } void OnTriggerEnter(Collider other) { if (other.tag == "Bullet") { Debug.Log(other.tag); if(HitCount<2) HitCount++; if (HitCount > 0) fSpeed = 0.0f; } } }