void Fire_Kill_Laser() { if (networkView.isMine || BasicFunctions.playOffline) { AudioSource.PlayClipAtPoint(kill_shot_sound, transform.position); RaycastHit hit; Ray ray = Camera.main.ScreenPointToRay(new Vector2(Screen.width / 2f, Screen.height / 2f)); if (Physics.Raycast(ray, out hit)) { LineRenderer KillLineCurrent = (LineRenderer)Instantiate(KillLine.GetComponent <LineRenderer>()); float Distance = Mathf.Sqrt((GunTransform.position - hit.point).sqrMagnitude); float floatvertexsize = VerticesPerUnit * Distance; vertexsize = (int)floatvertexsize; if (vertexsize > 30000) { vertexsize = 30000; } KillLineCurrent.SetVertexCount(vertexsize); KillLineCurrent.SetPosition(vertexsize - 1, GunTransform.position + new Vector3(0.01f, -0.01f, 0.01f)); for (int i = 1; i < (vertexsize - 1); i++) { float multiplier = ((i * 1.0f) / (vertexsize - 1)); KillLineCurrent.SetPosition(i, (multiplier * (GunTransform.position - hit.point)) + hit.point + new Vector3(Random.Range(-Gibrange, Gibrange), Random.Range(-Gibrange, Gibrange), Random.Range(-Gibrange, Gibrange))); } KillLineCurrent.SetPosition(0, hit.point); if (!BasicFunctions.playOffline) { int shootNumber = activeAccount.Number; KillLineCurrent.GetComponent <Gravity_trace_script>().shooterNumber = shootNumber; player.Fire_Kill_Bullet(GunTransform.position + new Vector3(0.01f, -0.01f, 0.01f), hit.point, shootNumber); } if (hit.collider.tag == "Player") { AudioSource.PlayClipAtPoint(bullet_hit_sound, transform.position); if (!referee) { referee = (GameObject.FindGameObjectsWithTag("Referee_Tag"))[0].GetComponent <Referee_script>(); } referee.frag(KillLineCurrent.GetComponent <Gravity_trace_script>().shooterNumber, hit.collider.gameObject.GetComponent <playerController>().playerNumber); } } } }
void OnTriggerStay(Collider hit) { if (networkView.isMine) { if (Can_Hit && hit.tag == "Player") // Input.GetKeyDown ("space")) { AudioSource.PlayClipAtPoint(stab_someone_sound, transform.position); if (!referee) { referee = (GameObject.FindGameObjectsWithTag("Referee_Tag"))[0].GetComponent <Referee_script>(); } if (hit.gameObject.GetComponent <playerController>().isAlive&& gameObject.transform.parent.parent.GetComponent <playerController>().isAlive) { referee.frag(playerScript.playerNumber, hit.gameObject.GetComponent <playerController>().playerNumber); Can_Hit = false; } } } }