void SendDamage2() { RaycastHit hit; if (Physics.Raycast(transform.position, transform.forward, out hit, 150)) { StainEnemyScript target2 = hit.transform.GetComponent <StainEnemyScript>(); target2.TakeDamage(damage); swingHit = false; } }
//shoot function, creates a raycast in front of player, if it hits the "Blue Enemy", that enemy's script is called and it takes damage public void Shoot() { muzzleFlash.Play(); RaycastHit hit; if (Physics.Raycast(transform.position, transform.forward, out hit)) { Debug.Log(hit.transform.name); GermEnemyScript target1 = hit.transform.GetComponent <GermEnemyScript>(); StainEnemyScript target2 = hit.transform.GetComponent <StainEnemyScript>(); //TEMP: Get targets gameobject to test if wrong weapon used GameObject targetGO = hit.transform.gameObject; if (target1 != null && target1.tag == "BlueEnemy") { staticForce += 1; target1.TakeDamage(damage); //TEMP: Notify on wrong weapon used } if (target2 != null && target2.tag == "Stain Enemy" && target2.stainHealth > 10) { staticForce += 1; target2.TakeDamage(damage); } else if (targetGO != null && targetGO.tag == "RedEnemy") { StartCoroutine("WrongWeaponNotify"); } //instantiates a particle system to simulate shot hitting the target, currently not working, no idea why GameObject impactGO = Instantiate(_impactEffect, hit.point, Quaternion.LookRotation(hit.normal)); impactGO.GetComponent <ParticleSystem>().Play(); } }