public void shot_f() { if (manager.is_player_turn(PhotonNetwork.player.ID)) { m_timer.stop_timer(); } Vector2 canon_angle_vec2 = new Vector2(diff_norm.x, diff_norm.y); canon_angle_vec2 *= -1; float distnace = Vector3.Distance(new_mouse_pos, good_tank.transform.position); float distnace_ratio = distnace / (max_amount_of_arrows * size_of_arrow); if (distnace > min_distance) { Vector2 fire_dir = canon_angle_vec2 * shoting_force * distnace_ratio; if (lpm.btn.name == "jump") { good_tank.GetComponent <Rigidbody2D>().AddForce(fire_dir); disable_tank_rigids(good_tank); } if (lpm.btn.name == "weapon") { Debug.Log(good_tank_canon_shoting_edge.transform.position); // 2 is the amount_of_players, beacuse right before the tanks layer, comes the bullets layers Debug.Log("layer"); Debug.Log(good_tank.layer); if (manager.is_player_turn(PhotonNetwork.player.ID)) { Debug.Log("shoting at my turn."); GameObject new_bullet = PhotonNetwork.Instantiate("bullet/" + good_tank_bullet.name, good_tank_canon_shoting_edge.transform.position, Quaternion.identity, 0, null); new_bullet.layer = good_tank.layer - 2; /*only controled by owner*/ new_bullet.GetComponent <Rigidbody2D>().isKinematic = false; new_bullet.GetComponent <Rigidbody2D>().AddForce(fire_dir); bullet_script new_bullet_script = new_bullet.GetComponent <bullet_script>(); photonView.RPC("new_bullet_RPC", PhotonTargets.All, new_bullet.GetComponent <PhotonView>().viewID, true, player_to_bullet_layer(PhotonNetwork.player.ID)); Debug.Log("shoting amount"); Debug.Log(new_bullet_script.bullet_amount); StartCoroutine(shot_bullets(PhotonNetwork.player.ID, fire_dir, good_tank_canon_shoting_edge.transform.position, good_tank_bullet.name, good_tank.layer - 2, new_bullet_script.bullet_amount - 1, new_bullet_script.wait_between_bullets)); /* * photonView.RPC("shot_RPC", PhotonTargets.All, PhotonNetwork.player.ID, fire_dir, good_tank_canon_shoting_edge.transform.position, * good_tank_bullet.name, good_tank.layer - 2); */ } } } }