void Update() { if (universeN() != -1) { manager = GameObject.Find("Character" + universeN()).GetComponent<PlayerManager>(); timer += Time.deltaTime; if (Network.isClient && myCharacter) { if (model == "china") spawnPosition = Random.value > 0.5 ? lSpawn.position : rSpawn.position; else spawnPosition = spawn.position; Camera cam = GameObject.Find("Camera " + universeN()).camera; Vector3 lookAt, dir; RaycastHit hit; Ray ray; if (rotated) { ray = cam.ScreenPointToRay(Input.mousePosition); ray.origin = spawnPosition; if (Physics.Raycast(ray, out hit, 1000)) lookAt = hit.point; else lookAt = ray.GetPoint(100); dir = ray.direction; } else { Vector3 mousePos = Input.mousePosition; mousePos.z = spawnPosition.z; ray = new Ray(cam.ScreenToWorldPoint(mousePos), Vector3.right); Debug.DrawRay(ray.origin, ray.direction * 100, Color.red); if (Physics.Raycast(ray, out hit, 100)) lookAt = hit.point; else lookAt = ray.origin; dir = lookAt - spawnPosition; } beam.SetPosition(1, lookAt); beam.SetPosition(0, spawnPosition); if (Input.GetButton("Primary Fire") && timer >= manager.wepStats.wepRate && manager.getEnergyLevel() != 0) { // Can I fire? if (manager.getEnergyLevel() - manager.getSelectedWepDrain() >= 0) { int wType = manager.wepType; string wDir = ""; switch(wType) { case 1: wDir = "beam/beam2"; break; case 2: wDir = "cannon/cannon"; break; case 3: wDir = "mine/mine"; break; default: wDir = "beam/beam2"; break; } networkView.RPC("PlayNetworkShot", RPCMode.All, wDir, manager.universeNumber); // Send message to fire if (dir.x > 0) networkView.RPC("fireWeapon", RPCMode.Server, lookAt, dir, spawnPosition, manager.wepStats.wepType); timer = 0; // Tell AchievementSystem //AchievementSystem.playerFired(); } } } } }