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 vj87 · Jan 06, 2015 at 08:13 AM · componentsenabledfalsetrue

How to set false components to true?

Alright so this has had me stumped for about a week or two. Well I'm trying to make my game online, so what I had to do for the networking player was have them start with the components below false. I try to set them true with my C# script but it is simply not working. I have no idea why. I'm not sure if you aren't able to set a component True after it's already been set to false or what. If you could please tell me what I'm doing wrong that would be fantastic!

~Thanks in advance

                                 ~A bit of my code just in case you need to see it~

                              ((MonoBehaviour)myPlayerGO.GetComponent("FPSInputController")).enabled = true;
             ((MonoBehaviour)myPlayerGO.GetComponent("MouseLook")).enabled = true;
             ((MonoBehaviour)myPlayerGO.GetComponent("CharacterMotor")).enabled = true;
             myPlayerGO.transform.FindChild("Main Camera").gameObject.SetActive(true);
 }
Comment
Add comment · Show 3
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 HarshadK · Jan 06, 2015 at 08:37 AM 0
Share

Does it throw any error/exception or something?

avatar image vj87 · Jan 06, 2015 at 11:37 PM 0
Share

No it doesn't unfortunantly :/

avatar image Cheese_Gaming · Jan 07, 2015 at 05:14 AM 0
Share

You're using Quill18's tutorial aren't you XD

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by KiraSensei · Jan 06, 2015 at 08:40 AM

With the code you have, the only thing that can go wrong is

 myPlayerGO.transform.FindChild("Main Camera").gameObject.SetActive(true);

Because if the main camera is not active, it will not be found. Since you want to activate it, I suppose it is not yet activated :)

So you need to do this :

 var mainCamera:GameObject;

And valuate in the inspector this variable with the corresponding game object in the scene.

And then :

 mainCamera.SetActive(true);

For the other lines of code, everything should be find if myPlayerGO is already an activated game object. If not, you need to activate it first like the main camera.

Comment
Add comment · Show 5 · 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 vj87 · Jan 06, 2015 at 11:36 PM 0
Share

Thanks that solved part of my problem :) However all of the other scripts are still false

GameObject myPlayerGO = (GameObject)PhotonNetwork.Instantiate ("PlayerController", mySpawnSpot.transform.position, mySpawnSpot.transform.rotation, 0);

That is what my variable "myPlayerGO" equals. I'm not sure if the script isn't understanding that myPlayerGO is apart of Player Controller or something (Sorry have a hard time explaining these types of things) But yeah if you could give me a sample script to get my online network up and running I would be super grateful.

Also I'd like to thank you again for taking the time to help me with this.

avatar image KiraSensei · Jan 06, 2015 at 11:46 PM 0
Share

Does your player controller prefab contains a mouse look script and an character controller script ?

avatar image vj87 · Jan 07, 2015 at 03:23 AM 0
Share

Yes it does. I mean looking at that is the only reason I know that everything remains false

avatar image vj87 · Jan 07, 2015 at 03:54 AM 0
Share

Wait never$$anonymous$$d! :D:D:D:D:D I finally fixed it! there was nothing wrong with my code or anything like that but I guess the script didn't like the order I had everything in lol. Thanks so much for the help though :)

avatar image KiraSensei · Jan 07, 2015 at 07:27 AM 0
Share

Ok, cool ! Please accept the answer to close the question byt ticking the check icon on the left side :)

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

4 People are following this question.

avatar image avatar image avatar image avatar image

Related Questions

yield waitforseconds false/true 2 Answers

How can I make 2 objects that are close to each other being treated as being in the same position? 1 Answer

Why does this simple script not work????? 0 Answers

scripting is not working for words "true" & "false" 1 Answer

True and False values with If and else 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