// Update is called once per frame void Update() { // this makes sure that the scene is loaded and we are connected to the server // the client then lets the server know it's ok to start the game if (_isPreConnection && Client.IsConnectedToServer) { Client.SceneReady(); _isPreConnection = false; } // don't allow input when the game isn't running if (_isGameRunning) { if (Input.GetButtonDown("HopP1")) { Client.HopButtonPressed(); } // ignore second local input if playing multiplayer if (StateManager.isServerSimulated) { if (Input.GetButtonDown("HopP2")) { Client.LocalP2HopPressed(); } } } }
//public override void OnStartLocalPlayer() //{ // //base.OnStartLocalPlayer(); // GetComponent<MeshRenderer>().material.color = Color.blue; //} //[Command] public void CmdFire() { GameObject bullet = (GameObject)Instantiate(bulletPrefab, bulletSpawn.position, bulletSpawn.rotation); bullet.GetComponent <Rigidbody>().velocity = -bullet.transform.right * 6.0f; //NetworkServer.Spawn(bullet); Client.HopButtonPressed(); Destroy(bullet, 2); }