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 /
avatar image
0
Question by AdamEstone · Aug 08, 2011 at 10:50 PM · pausedisableenable

Disable a script from another script

Hello,

I have a problem: i can't disable a script from an other script. why? I am making a menu, and i want to stop my player moving, when it is on pause. Or is there an other way to do it?alt text

 // the var 'P' = pause
 static var P=0;
 function Update () {
 // i did define the escape button! 
  if(Input.GetButtonDown("esc")){
     P=1;
  }
 }
 function OnGUI()
 {
  if (P==1){
            Screen.showCursor = true;
 
            GUI.Box(Rect(-45,0,2000,1000), "Pause");
            if(GUI.Button(Rect(910,300,100,30), "Resume")){P=0; Screen.showCursor = false;}
            if(GUI.Button(Rect(910,500,100,30), "Exit")){Application.Quit();}
 
   /*Error-->*/ gameObject.Find("FirstPersonControllerPrefab").FPSWalker = false;
   /*Error-->*/ gameObject.Find("FirstPersonControllerPrefab").FPSWalker.enable = false;
   /*Error-->*/ gameObject.Find("FirstPersonControllerPrefab").FPSWalker.false;
   /*Error-->*/ gameObject.Find("FirstPersonControllerPrefab").FPSWalker.active = false;
         
  }
 }


Please help! ASAP!!! :-/

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

2 Replies

· Add your reply
  • Sort: 
avatar image
3
Best Answer

Answer by SisterKy · Aug 08, 2011 at 11:20 PM

Try ...FPSWalker.enable*d* = false; If that still gives an error, please tell us what it's saying

Comment
Add comment · Show 4 · Share
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 AdamEstone · Aug 08, 2011 at 11:29 PM 0
Share

"If that still gives an error, please tell us what it's saying"

NullReferenceException: Object reference not set to an instance of an object Boo.Lang.Runtime.RuntimeServices.GetDispatcher (System.Object target, System.String cache$$anonymous$$eyName, System.Type[] cache$$anonymous$$eyTypes, Boo.Lang.Runtime.DynamicDispatching.DispatcherFactory factory)

it say it is at that line with: ...FPSWalker.enabled = false;

avatar image SisterKy · Aug 08, 2011 at 11:33 PM 1
Share

thanks for turning this into a comment ins$$anonymous$$d of an answer :)

oh, stupid me! How did I miss this? shakes her head! Sorry... Of course. you have to use

gameObject.Find("FirstPersonControllerPrefab").GetComponent(FPSWalker).enabled = false;

avatar image TomatoOrgyLT · Jan 26, 2013 at 08:49 PM 0
Share

When I try to do this I get an error message saying BCE0019: 'GetComponent' is not a member of 'UnityEngine.GameObject[]'. Why?

avatar image sona.viswam · Mar 08, 2013 at 12:07 PM 0
Share

its not working. then how will you check it as correct answer?

avatar image
0

Answer by Tknoguyfication · Mar 20, 2014 at 06:33 PM

It's easier to do time.Timescale = 0;

Comment
Add comment · Share
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

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

7 People are following this question.

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

Related Questions

Disable SCRIPT HELP!!!! 1 Answer

Script Not staying disabled 2 Answers

Turn Off/on culling mask by script? 2 Answers

disable/enable mouselook not working? 1 Answer

Enable/Disable GameObject Button script 1 Answer


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