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 /
This question was closed Apr 29, 2018 at 11:01 PM by doctoct for the following reason:

The question is answered, right answer was accepted

avatar image
0
Question by doctoct · Apr 23, 2018 at 04:53 AM · scripting problemprogramminghelloworld

Trying to disable the Script below on trigger or the closest thing

 using System.Collections;
 using System.Collections.Generic;
 using UnityEngine;
 using UnityStandardAssets.Characters.FirstPerson;
 
 public class PauseGame : MonoBehaviour
 {
     public Transform canvas;
     public Transform Player;
 
     void Update()
     {
         if (Input.GetKeyDown(KeyCode.Escape))
         {
               
             {
                 Cursor.lockState = CursorLockMode.None;
                 Cursor.visible = true;
                 Pause();
             }
         }
     }
    public void Pause()
     {
         if (canvas.gameObject.activeInHierarchy == false)
         {
             canvas.gameObject.SetActive(true);
             Time.timeScale = 0;
             Player.GetComponent<FirstPersonController>().enabled = false;
         }
         else
         {
             canvas.gameObject.SetActive(false);
             Time.timeScale = 1;
             Player.GetComponent<FirstPersonController>().enabled = true;
         }
     }
 }
 

I need to disable this Script when I hit a trigger so I can no longer pause at the game end menu. I've tried destroying the object and that gets rid of my Canvas which is great but my Time.timeScale = 1 still activates when pressing Esc. Anything yall can think of is greatly appreciated!!!

Comment
Add comment · Show 2
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
avatar image doctoct · Apr 23, 2018 at 05:01 AM 0
Share
 using UnityEngine;
 using UnityEngine.UI;
 using UnityStandardAssets.Characters.FirstPerson;
 
 public class CursorVis : $$anonymous$$onoBehaviour
 {
     
     public Transform canvas;
     public Transform Player;
     
     void OnTriggerEnter(Collider other)
     {
         if (other.CompareTag("Player"))
 
         {
                        
             canvas.gameObject.SetActive(true);
             Player.GetComponent<FirstPersonController>().enabled = false;
             Time.timeScale = 0;
             Cursor.lockState = CursorLock$$anonymous$$ode.None;
             Cursor.visible = true;
 
            
         }
     }  
 
 }
 "This is my trigger object. I'd like to add the solution into this script" They're both using separate Canvas's. The first script activates my pause menu on esc. The second is my trigger to show my end game Canvas. 
avatar image kaplica · Apr 23, 2018 at 09:36 AM 0
Share

It seems like you are over-complicating things here. Just use boolean values for checking things like this. So if game end menu is enabled, set the bool value for pausing accordingly and pausing is not possible then.

ex:

if(canPause) { // Pause } else { // Cannot Pause }

0 Replies

  • Sort: 

Follow this Question

Answers Answers and Comments

146 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 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

Multiple Cars not working 1 Answer

How to follow a target (prefab) with the visual scripting: Behavior machine Pro? 0 Answers

TouchControls/MouseInput HELP PLEASE 0 Answers

Is that possible to get real time data from my sensor in io.adafruit.com transferred to unity ? what should i do? 1 Answer

How do I reference a class to pass on variables in that class? 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