Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 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 WesterlyCarrot9 · May 02, 2013 at 12:50 AM · javascripttriggertimemouselook

Screen go Gray and only Cursor active OnTriggerEnter

Greetings! So i have those two scripts below. One attached to my Floor and the other to my Player. Is there a way to make the screen go gray as soon as the player enter the Trigger and make only the cursor active not the whole mouselook script of the First Person Controller? I tried using Time.timeScale but only the movement was frozen. I could still look around with the mouse. Thanks!

 TriggerFloor.js
 
 var showGUI : boolean = false;
 var original : Vector3;
 var player : GameObject;
 
 function Start(){
     player = GameObject.Find("Player");
     original = player.transform.position;
 }    
 
 function OnTriggerEnter(other:Collider){
 
     if(other.gameObject.name == "Player"){
         var otherScript = player.GetComponent(FallDamage); 
         otherScript.hearts -= 1;
         showGUI = true;
     }    
 }
 
 function OnGUI(){
     if(showGUI){
         if(GUI.Button(new Rect(20,70,100,50), "Respawn")){
             player.transform.position = original;
             showGUI = false;
         }
     }
 }


 FallDamage.js
 
 var hearts : int = 3;
 
 function OnGUI(){
     GUI.Box(new Rect(20,20,100,40), "Hearts : " + hearts);
     
     if(hearts < 0){
         hearts = 0;
         Destroy(this.gameObject);
     }                
 }

     

     
 
Comment
Add comment · Show 1
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 WesterlyCarrot9 · May 02, 2013 at 01:16 PM 0
Share

Someone???

1 Reply

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

Answer by ExTheSea · May 02, 2013 at 05:14 PM

So to make the screen go gray you could use something like in this answer: http://answers.unity3d.com/questions/31193/screen-flashes-red-when-taking-damage.html

and to disable the mouseLook-Script you could do somthing like this:

 var theCamera : GameObject; //Assign the Camera or gameobject which has the mouselook-script attached
 
 ...
 
 theCamera.GetComponent("MouseLook").enabled = false;

If you need to disable other scripts to make it work you can do it similar. just get the component and set its enabled state to false.

Good Luck.

ExTheSea

Comment
Add comment · Show 6 · 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 WesterlyCarrot9 · May 02, 2013 at 10:59 PM 0
Share

Ok i don't about the gray screen yet. I haven't tried it yet :P And actually i don't want to have a flash for a second or two. I want my screen to become gray and feel like the game is paused. About the $$anonymous$$ouseLook your example worked except that i still can move the camera up and down with the cursor :S What should i add?

avatar image ExTheSea · May 03, 2013 at 03:46 PM 0
Share

You need to fin which script is is making the camera move up and down still because the $$anonymous$$ousLook-Script is disabled so it can't be it. When you find the script which is still making the camera move u can disable it by thegameojectitson.GetComponent("TheScript").enabled = false;

Btw. It wouldn't be an option for you to remove or disable the player/camera and then activating/instantiating another one to do the GUI stuff?

avatar image WesterlyCarrot9 · May 03, 2013 at 05:47 PM 0
Share

Ok i get it. I'll try to locate that other script. About the last part you wrote, hmm what i want is when my Player falls down on the floor and enters the trigger, the whole game will kind of pause and the screen will go gray and the respawn button will appear. Now that i think about it though, maybe i'll do it possible with just one button :P

avatar image Justei · May 03, 2013 at 06:06 PM 0
Share

What you should consider in the case you are describing, is using some kind of Image Effect (are you using Unity Pro?) when pausing, on the camera of course. And also of course pause the mouse movement just like ExTheSea has described.

avatar image WesterlyCarrot9 · May 03, 2013 at 09:41 PM 0
Share

No just the Free version of it. I see. Thanks a lot guys! I'll see what i can do by myself. Eventually, i'll make it happen :)

Show more comments

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

14 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

Related Questions

Breathing sound effect using timers 1 Answer

OnTriggerEnter can't detect my Transform tag 1 Answer

Check for collision while animating 0 Answers

Help With Quickest TimeScore 0 Answers

fps MouseLook with animation applied to camera. 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