Other
how to disable the pause menu oppening over the death screen if player is dead, and how to stop camera movement when player is dead.
hello, i need help really fast, i made a death screen and when my player dies he can look around and press escape to open the pause menu, and then when he presses it again game just keeps on going with death screen on. I dont want that, i need when my player dies that he cant look around and he cant press escape.
By the way if someone would be so kind to make me a better camera script, here player can only look left and right, but not up and down, and also the player is rotating when player presses W, i also need: so player can look around full 360 degrees and when you turn the camera he keeps rolling in direction you are looking towards.
but i need the first part more so here are my scripts:
Camera:
using UnityEngine; using System.Collections;
public class CameraMovement : MonoBehaviour {
public float turnSpeed = 7.0f;
public Transform player;
public Transform PauseMenu1;
public float height = 2f;
public float distance = 5f;
private Vector3 offsetX;
void Start()
{
offsetX = new Vector3(0, height, distance);
}
void LateUpdate()
{
offsetX = Quaternion.AngleAxis(Input.GetAxis("Mouse X") * turnSpeed, Vector3.up) * offsetX;
transform.position = player.position + offsetX;
transform.LookAt(player.position);
if (PauseMenu1.gameObject.activeInHierarchy)
{
PauseOnDeath();
}
else
turnSpeed = 7.0f;
}
public void PauseOnDeath()
{
turnSpeed = 0;
}
}
Player Health:
using UnityEngine; using System.Collections;
public class CameraMovement : MonoBehaviour {
public float turnSpeed = 7.0f;
public Transform player;
public Transform PauseMenu1;
public float height = 2f;
public float distance = 5f;
private Vector3 offsetX;
void Start()
{
offsetX = new Vector3(0, height, distance);
}
void LateUpdate()
{
offsetX = Quaternion.AngleAxis(Input.GetAxis("Mouse X") * turnSpeed, Vector3.up) * offsetX;
transform.position = player.position + offsetX;
transform.LookAt(player.position);
if (PauseMenu1.gameObject.activeInHierarchy)
{
PauseOnDeath();
}
else
turnSpeed = 7.0f;
}
public void PauseOnDeath()
{
turnSpeed = 0;
}
}
and Pause menu:
using System.Collections; using System.Collections.Generic; using UnityEngine;
public class PauseMenu : MonoBehaviour {
public Transform PauseMenu1;
public Transform Player;
void Start ()
{
Cursor.lockState = CursorLockMode.Confined;
Cursor.lockState = CursorLockMode.Locked;
Cursor.visible = false;
}
void Update()
{
if (Input.GetKeyDown(KeyCode.Escape))
{
Cursor.visible = true;
Cursor.lockState = CursorLockMode.None;
Pause();
}
}
public void Pause ()
{
if (Input.GetKeyDown(KeyCode.Escape))
{
if (PauseMenu1.gameObject.activeInHierarchy == false)
{
Cursor.visible = true;
Cursor.lockState = CursorLockMode.None;
PauseMenu1.gameObject.SetActive(true);
Time.timeScale = 0;
}
else
{
Cursor.lockState = CursorLockMode.Locked;
Cursor.visible = false;
Play();
}
}
}
private void Play()
{
Cursor.lockState = CursorLockMode.Locked;
Cursor.visible = false;
PauseMenu1.gameObject.SetActive(false);
Time.timeScale = 1;
}
}
Follow this Question
Related Questions
Rotate ball in camera's direction.... 0 Answers
Transform.Rotate x and y rotate z, where z is 0 0 Answers
Camera X Rotation Problems 0 Answers