Example #1
0
    public void Attack()
    {
        Attacking = true;
        RaycastHit SwordHit;

        if (Physics.Raycast(headBone.transform.position, headBone.transform.forward, out SwordHit, HitDistance, RaycastMask))
        {
            if (SwordHit.transform.tag == "Player")
            {
                FPSController ply = SwordHit.transform.GetComponent <FPSController>();
                if (!ply.Blocking)
                {
                    ply.HitDamaged(1);
                    StartCoroutine(Knockback(SwordHit));
                    SoundOrigin = SoundSource.transform.localPosition;
                    SoundSource.transform.position = SwordHit.point;
                    EnemySounds.PlaySound(HitSound);
                    SoundSource.transform.localPosition = SoundOrigin;
                    GameObject ParticleEmitter = Instantiate(BloodEmitter, SwordHit.point, Quaternion.LookRotation(SwordHit.normal));
                    StartCoroutine(GCParticles(ParticleEmitter));
                }
                else
                {
                    SoundOrigin = SoundSource.transform.localPosition;
                    SoundSource.transform.position = SwordHit.point;
                    EnemySounds.PlaySound(BlockSound);
                    SoundSource.transform.localPosition = SoundOrigin;
                    GameObject ParticleEmitter = Instantiate(DustEmitter, SwordHit.point, Quaternion.LookRotation(SwordHit.normal));
                    StartCoroutine(GCParticles(ParticleEmitter));
                }
            }
        }
    }
 void OnTriggerEnter(Collider collider)
 {
     if (collider.tag == "Player")
     {
         FPSController plyc = collider.GetComponent <FPSController>();
         if (!plyc.isGrounded)
         {
             plyc.HitDamaged(3);
         }
     }
 }