Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
  • Help Room /
This question was closed Jan 03, 2018 at 02:51 PM by Wi8games for the following reason:

Other

avatar image
0
Question by Wi8games · Mar 31, 2017 at 07:15 PM · camerarotationballdeathpause menu

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;

 }
 }
Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

0 Replies

  • Sort: 

Follow this Question

Answers Answers and Comments

131 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

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

Rotation around player. and Camera position, 2 Answers

How to bring UI element infront of other objects? 0 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges