public void     destroyEnemy()
        {
            RaycastHit hit;


            Ray ray = new Ray(transform.position, transform.forward);

            Debug.DrawRay(transform.position, transform.forward * rayDist, Color.red);

            if (Physics.Raycast(ray, out hit, rayDist))
            {
                GameObject freezeObj = hit.transform.gameObject;

                Debug.Log("true");
                if (freezeObj != null)
                {
                    EnemyMTP frzNME = freezeObj.GetComponentInChildren <EnemyMTP> ();
                    Animator anim   = freezeObj.GetComponentInChildren <Animator> ();
                    if (frzNME != null && frzNME.isDestroyable == true)
                    {
                        //Destroy (freezeObj);
                        anim.SetBool("isHit", frzNME.isDestroyable);
                        point++;

                        //Destroy (this.gameObject);
                    }
                }
            }
        }
Beispiel #2
0
        //float freezeTime = 3;
        //Rigidbody rb;
        //	public void OnCollisionEnter(Collision other)
        //	{
        //		if (other.gameObject.name == "Projectile")
        //		{
        //			GetComponent<Rigidbody> ().constraints = RigidbodyConstraints.FreezeAll;
        //			//rb.constraints=RigidbodyConstraints.FreezeAll;
        ////			transform.Translate (new Vector3 (0, 0, 0));
        ////			Destroy (this.gameObject);
        //			Debug.Log ("hit");
        //		}
        //	}
        public void stunEnemy()
        {
            RaycastHit hit;

            Ray ray = new Ray(transform.position, transform.forward);

            Debug.DrawRay(transform.position, transform.forward * rayDist, Color.red);

            if (Physics.Raycast(ray, out hit, rayDist))
            {
                GameObject objhit = hit.transform.gameObject;

                if (objhit != null)
                {
                    EnemyMTP nme = objhit.GetComponentInChildren <EnemyMTP> ();
                    if (nme != null)
                    {
                        nme.isStun = true;
                    }
                }
            }
        }