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 keyp3r · Aug 29, 2012 at 09:00 PM · activeenabled

Enabling/Disabling components disabling my GameObject?

I'm trying to do something I've done a million times, disable the MouseLook component of the main camera and the character controller on the default FPS character controller. This is how I'm trying to do it:

private Camera mainCam; private MouseLook camLook; private GameObject plyr; private MouseLook plyrLook;

 void Start () {
     plyr = GameObject.FindWithTag("Player");
     plyrLook = plyr.GetComponent<MouseLook>();
     mainCam = Camera.main;
     camLook = mainCam.GetComponent<MouseLook>();
 }
     
     // Update is called once per frame
 void Update () {
     if(Input.GetButtonDown("RotateHeld") && heldItem){
         Rotating=true;
         plyrLook.active=false;
         camLook.active=false;
     }
     else if(Input.GetButtonUp("RotateHeld") && heldItem){
         Rotating=false;
         camLook.active=true;
         plyrLook.active=true;
     }
 
 }

Its part of a simple script to let the player pick up and rotate an object. But when I say "plyrLook.active=false;" it disabled the whole GameObject associated with it for no reason I can see. The same happens with camLook... I'm at a loss...

Also, as a side note it keeps throwing a warning about me using ".active" and says that I should be using ".enabled" instead, but when I change it it says that doesent exist. This has been an on going thing, I've just ignored it but if anyone has an answer to that one too, that'd be awesome.

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 gegc · Aug 29, 2012 at 10:00 PM

Didn't they change that so it was "enabled" for Components and "active" for GameObjects? So if you wanted to disable a component you would do comp.enabled = false, and when you wanted to disable a whole gameobject you'd do obj.active = false. Intellisense yells at me when I do component.active.

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 keyp3r · Aug 29, 2012 at 10:24 PM 0
Share

Yeah that fixed it. Friend of $$anonymous$$e said the same thing actually! I wasn't getting any errors so I assumed they'd keep it as one command for everything, being thats the logical thing. Thanks!

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

9 People are following this question.

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

Related Questions

.enabled does not enabled GUItexture 1 Answer

unity 2d trigger a script with a trigger? 0 Answers

script wont re activate object when my conditions are met 1 Answer

Button to create object??? 1 Answer

What is the difference between these three ways of making an object disappear? 3 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