private void shoot() { scoreManager.AddToShots(); //store raycast information RaycastHit hit; if (Physics.Raycast(muzzle.transform.position, muzzle.transform.forward, out hit, RayCastRange)) { //Debug.Log(hit.transform.name); //store target component thats been hit Target_Parent currentTarget = hit.transform.GetComponent <Target_Parent>(); //check if we hit an object that actually had a target component if (currentTarget != null) { currentTarget.hit(); } } //show debug of where its shooting Debug.DrawLine(muzzle.transform.position, muzzle.transform.position + muzzle.transform.forward * 100, Color.green, 3f); //fire bullet trail if (GameManager.Instance.useTrail && !constantFire) { bulletTrail.shootTrail(); } }
//when target is no longer needed, add to array in target manager for score public static void addTarget(Target_Parent target)//changed from Target Obj { //add target to list of targets hit, only if target manager wants to record if (isRecording) { targets.Add(target); } //update the max amount of targets on screen currentTargets = currentTargets - 1; //destroy object Destroy(target.gameObject); //Debug.Log(targets.Count); }