// Update is called once per frame void Update() { if (SceneManager.GetActiveScene() == SceneManager.GetSceneByName("TestScene")) { if (!LoadedScene) { Cursor.visible = false; Cursor.lockState = CursorLockMode.Locked; LoadedScene = true; } if (OverlayActive.IsOverlayActive()) { Cursor.visible = true; Cursor.lockState = cursorLockMode; } else { Cursor.visible = false; Cursor.lockState = CursorLockMode.Locked; } } else { Cursor.visible = true; Cursor.lockState = CursorLockMode.None; } }
// Update is called once per frame void Update() { if (isLocalPlayer) { OnOverlayActive(!OverlayActive.IsOverlayActive()); if (GetComponent <Health>().currentHealth <= 0.0f && isDead == false) { Die(); } else if (isDead) { //GetComponent<Rigidbody>().AddForce(0, -500, 0); //**Dropping Down code****/ this.gameObject.transform.position += Vector3.down * 2; this.gameObject.transform.Rotate(0, 0, 5); //************************/ if (killerName != "") { if (killerName != this.name) { GetComponent <PlayerSetup>().GetPlayerUI().GetRespawnScreen().SetKillerText(killerName); } else { GetComponent <PlayerSetup>().GetPlayerUI().GetRespawnScreen().SetKillerText("Myself"); } } respawnTimer -= Time.deltaTime; GetComponent <PlayerSetup>().GetPlayerUI().GetRespawnScreen().SetRespawnTimerText(((int)respawnTimer).ToString()); if (respawnTimer <= 1f) { Respawn(); } } // For testing if (Input.GetKeyDown(KeyCode.K)) { GetComponent <Health>().currentHealth = 0; killerName = this.gameObject.name; } updateInterval += Time.deltaTime; if (updateInterval > 0.11f) { CmdSync(isDead, hasRespawned); } } else { isDead = real_isDead; hasRespawned = real_hasRespawned; RemotePlayerDead(); } }
void Update() { if (!playerScript.isLocalPlayer || OverlayActive.IsOverlayActive()) { return; } //Debug.Log(playerScript.name); // Rotate //UpdatePitch(); //UpdateYaw(); // Update rotation values float playerPitch = playerScript.GetPitch(); float playerYaw = playerScript.GetYaw(); if (this.pitch != playerPitch) { if (this.pitch < playerPitch) { this.pitch += (playerPitch - this.pitch) * changeSpeed * Time.deltaTime; if (this.pitch > playerPitch) { this.pitch = playerPitch; } } else { this.pitch -= (this.pitch - playerPitch) * changeSpeed * Time.deltaTime; if (this.pitch < playerPitch) { this.pitch = playerPitch; } } } if (this.yaw != playerYaw) { if (this.yaw < playerYaw) { this.yaw += (playerYaw - this.yaw) * changeSpeed * Time.deltaTime; if (this.yaw > playerYaw) { this.yaw = playerYaw; } } else { this.yaw -= (this.yaw - playerYaw) * changeSpeed * Time.deltaTime; if (this.yaw < playerYaw) { this.yaw = playerYaw; } } } //this.pitch = playerScript.GetPitch(); //this.yaw = playerScript.GetYaw(); this.roll = playerScript.GetRoll(); // rotate player //player.transform.eulerAngles = new Vector3(-pitch, yaw, -yaw * 0.5f); // move camera this.transform.position = player.transform.position; this.transform.Translate(positionOffset); //Quaternion destRotate = Quaternion.Euler(-playerPitch + 30f, playerYaw, roll); ////Vector3 destination = player.transform.position + positionOffset; //Vector3 destination = positionOffset; //destination = destRotate * destination + player.transform.position; //Vector3 moveDir = (destination - this.transform.position).normalized; //this.transform.position += moveDir * Time.deltaTime * 500f; // //Vector3 dist = destination - this.transform.position; //double cosOfAngle = (moveDir.x * dist.x + moveDir.y * dist.y + moveDir.z * dist.z); //if (cosOfAngle < 0) // -ve, parallel & opp direction //{ // this.transform.position = destination; //} // rotate camera this.transform.eulerAngles = new Vector3(-pitch + cameraPitchOffset, yaw, roll); // rotate up vector //float playerRoll = playerScript.GetRoll(); //this.transform.up = new Vector3(playerRoll, 0f, 0f); //Vector3 right = Vector3.Cross(playerScript.GetView(), this.transform.up); //right.y = 0f; //right.Normalize(); //this.transform.up = Vector3.Cross(right, playerScript.GetView()); // rotate view vector //Quaternion rotation = Quaternion.Euler(-pitch, yaw, 0f); //playerScript.SetView(new Vector3(0, 0, 1)); //playerScript.SetView(rotation * playerScript.GetView()); // change target Quaternion euler = Quaternion.Euler(-pitch + cameraPitchOffset, yaw, 0f); cameraDir = euler * new Vector3(0, 0, 1); target.transform.position = this.transform.position + 1000f * cameraDir; }
public void ToggleRespawnScreen() { respawnScreen.SetActive(!respawnScreen.activeSelf); OverlayActive.SetOverlayActive(!OverlayActive.IsOverlayActive()); }
public void TogglePauseMenu() { pauseMenu.SetActive(!pauseMenu.activeSelf); OverlayActive.SetOverlayActive(!OverlayActive.IsOverlayActive()); //PauseMenu.isOn = pauseMenu.activeSelf; }