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 kikoncuo · Jan 02, 2015 at 06:25 PM · instantiatecanvaseventsystem

Photon give priority to Canvas Input (Event System)

Hi I´m trying to learn how to make a first person multiplayer game game, and I have a problem, I have a menu which appears before I instantiate the player and I want to also be able to make it appear when a button is pressed.

My problem is that I can't interact with the menu since the player controller takes over, nor I know how to deactivate the player since there are multiple instances of it and it's created on runtime.

 void Update(){   //Update is the only way I know to check if certain key is pressed
     if (Input.GetKeyDown(KeyCode.Escape)){  //The key is Escape
         bool estado=serverWindow.activeSelf; //I get if the options/server window is pressed
         serverWindow.SetActive(!estado);//I activate/deactivate it
         messagesWindow.SetActive (estado);//I deactivate the chat window since its not needed when the menu is in use

     }
 }

This is the code I use to activate the menu and deactivate the chat

https://www.youtube.com/watch?v=yb0XymjusBc

Here is a link to a less than 30s video showing my problem

Thank you for your time :)

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

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by Maurice_B · Jan 02, 2015 at 08:18 PM

to disable all the playercontrollers:

on the playercontroller script:

 static boolean cancontrol = true; //or false?
 void start(){
 //whatever you have here
 
 
 } 
 void Update (){
 if (cancontrol){
 //most code here
 
 
 }
 }

(This probably isnt perfect as i usually code in js but the principle is the same)

on the menu:

 void Update(){   //Update is the only way I know to check if certain key is pressed
      playercontrollerscriptnamehere.cancontrol = false;
      if (Input.GetKeyDown(KeyCode.Escape)){  //The key is Escape
          bool estado=serverWindow.activeSelf; //I get if the options/server window is pressed
          serverWindow.SetActive(!estado);//I activate/deactivate it
          messagesWindow.SetActive (estado);//I deactivate the chat window since its not needed when the menu is in use
          //dont forget playercontrollerscriptnamehere.cancontrol =true when the menu is closed
      }
  }

Explanation: Static variables are the same on all instances of a script so you can controll them all at runtime. Good luck.

Maurice

Comment
Add comment · Show 1 · 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 kikoncuo · Jan 02, 2015 at 09:02 PM 0
Share

Thanks for taking the time to answer my question, and sorry I realized I didn't explain what I needed properly. I know that's what I need to do, but I don't know how to access the controllerscript since I instantiate the player at runtime (photon.instantiate) and multiple instances of players are in the game. I tried finding the player by tag but all players have the same tag.

 if (Input.Get$$anonymous$$eyDown($$anonymous$$eyCode.Escape)){
             bool state=serverWindow.activeSelf;
             GameObject player = GameObject.FindGameObjectsWithTag("Player");
             player.GetComponent<controller>().enabled=state;
             serverWindow.SetActive(!state);
             messagesWindow.SetActive (state);
 
         }

I know you can do .Is$$anonymous$$ine when in photon, but I don't know how to use it properly, can I just call it in a gameobject? if so how?

Thanks again

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

3 People are following this question.

avatar image avatar image avatar image

Related Questions

Multi Camera HUD buttons not working. 1 Answer

Not instantiating prefab in the right place after 2017 update 2 Answers

Setting parent of instantiated sprite 2 Answers

EventSystem: how to highlight instantiated button? 1 Answer

Highlight button via script at runtime 5 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