public void RpcTakeDamage(string _PlayerID, float amount) { TankHealth tankHealth = GameManager_Net.Getplayer(_PlayerID).GetComponent <TankHealth>(); // Adjust the tank's current health, update the UI based on the new health and check whether or not the tank is dead. tankHealth.TakeDamage(amount); Debug.Log("hit recieved from client side"); }
public override void OnStartClient() { base.OnStartClient(); NetID = playerName; GameObject _player = GameObject.Find("OnlineTank(Clone)"); GameManager_Net.RegisterPlayer(NetID, _player); startPos = gameObject.transform.position; _player.name = playerName; m_PlayerNameDisplay.text = _player.name; MeshRenderer[] renderers = gameObject.GetComponentsInChildren <MeshRenderer>(); for (int i = 0; i < renderers.Length; i++) { // ... set their material color to the color specific to this tank. renderers[i].material.color = playerColor; } }
void CmdFire() { //RpcFire(); // Set the fired flag so only Fire is only called once. m_Fired = true; // Create an instance of the shell and store a reference to it's rigidbody. GameObject shellInstance = Instantiate(m_Shell, m_FireTransform.position, m_FireTransform.rotation); // Set the shell's velocity to the launch force in the fire position's forward direction. shellInstance.GetComponent <Rigidbody>().velocity = m_CurrentLaunchForce * m_FireTransform.forward; foreach (var instance in GameManager_Net.players) { if (GameManager_Net.Getplayer(instance.Key).GetComponent <NetworkIdentity>().hasAuthority) { authority = GameManager_Net.Getplayer(instance.Key); } } // Spawn the shell on the clients NetworkServer.SpawnWithClientAuthority(shellInstance, authority); // NetworkServer.Spawn(shellInstance); // Change the clip to the firing clip and play it. m_ShootingAudio.clip = m_FireClip; m_ShootingAudio.Play(); // Reset the launch force. This is a precaution in case of missing button events. m_CurrentLaunchForce = m_MinLaunchForce; }
// Получаем ссылки на объекты. private void Awake() { GameMasterGO = GameObject.FindGameObjectWithTag("GM"); GM = (GameManager_Net)GameMasterGO.GetComponent(typeof(GameManager_Net)); myRigidBody = GetComponent <Rigidbody2D>(); }