/// <summary> /// /// shoot method to play particle and audio /// also send a raycast out to the target - using TargetScript /// if target is not null, target to take damage /// </summary> void Shoot() { gunParticle.Play(); gunAudio.Play(); RaycastHit hit; if (Physics.Raycast(transform.position, transform.forward, out hit, range)) { JavaTarget1 target = hit.transform.GetComponent <JavaTarget1>(); MarkovChain target2 = hit.transform.GetComponent <MarkovChain>(); if (target != null) { target.DamageToTarget(damage); } if (target2 != null) { target2.DamageToTarget2(damage); } } }