Quantcast
Channel: Questions in topic: "help me"
Viewing all articles
Browse latest Browse all 115

Locking the cameras Y axis in pause

$
0
0
So in my pause menu I have found out how to lock everything I can exept for the cameras Y-axis movement. I've looked up all kinds of stuff and cant figure it out. Anyone know what I should do? Thanks using UnityEngine; using System.Collections; public class pauseMenu : MonoBehaviour { public GUISkin myskin; private Rect windowRect; private bool paused = false, waited = true; private void Start(){ windowRect= new Rect(Screen.width /2 - 100, Screen.height /2 -100, 200, 200); } private void waiting(){ waited = true; } private void Update(){ if(waited) if(Input.GetKey(KeyCode.Escape) || Input.GetKey(KeyCode.P)){ if(paused == true) paused = false; else paused = true; waited = false; Invoke("waiting",0.3f); } if (paused == true) { //makes cursor appear when in the menu Cursor.visible = true; //disables player movement gameObject.GetComponent().enabled = false; //camera cannot look horizontally gameObject.GetComponent().enabled = false; //disables shooting gameObject.GetComponent().enabled = false; } else { //Cursor is not visible when not in the menu Cursor.visible = false; //Player can move when menu is not up gameObject.GetComponent().enabled = true; //Camera can look horizontally when menu not up gameObject.GetComponent().enabled = true; //Shooting when not in menu gameObject.GetComponent().enabled = true; } } private void OnGUI(){ if (paused) windowRect = GUI.Window(0, windowRect, windowFunc, "Pause Menu"); } private void windowFunc(int id){ //Exits Pause if(GUILayout.Button("Resume")){ paused = false; } //Options for game if(GUILayout.Button("Options")){ //Audio and Video Settings } //Quits the game if(GUILayout.Button("Exit Game")){ Application.Quit(); } } }

Viewing all articles
Browse latest Browse all 115

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>