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 /
  • Help Room /
avatar image
0
Question by Jojoba007 · Feb 16, 2017 at 10:14 AM · forcesliderdisableenabledshow

Slider Fill Area deactivate after jump

I have a slider that shows the force of my characters jump. The longer you hold the mouse the higher he jumps. When he jumps and is in air I have the force disabled so the character won't dubble jump. But the slider Fill Area still visually increases when holding the mouse down. How can I disable this?

powerBar.interactable = false; doesn't seem to work

powerBar.enable doesn't seem to work either.

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
0
Best Answer

Answer by Jojoba007 · Feb 17, 2017 at 12:44 PM

@ArmanDoesStuff What .SetActive does is hide the whole Slider. I would like to only have the fill area of the slider not working anymore after jumping, so you won't be able to increase the fill while in mid air.

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 ArmanDoesStuff · Feb 17, 2017 at 01:13 PM 0
Share

Oh, right. It's quite hard to visualise what you mean without seeing the code but I think I get what you mean.

So you don't want to disable the slider fill, you just want to fix its value after the jump? In that case, couldn't you just disable anything that is affecting the slider value?

Again, I havn't seen your code but I imagine even something super simple like creating a "bool isJumping" that sets true after the jump, and then only have the mouse increase the jump power/slider value "if (isJumping == false)"

avatar image Jojoba007 ArmanDoesStuff · Feb 19, 2017 at 10:45 AM 0
Share

@ArmanDoesStuff

thanks for the respons.

If I jump and I'm in mid air the powerBar won't effect the characters jump force anymore, but I can still visually see the slider go up again while clicking again after jump in mid air. I'm trying to disable the fill area responding to the mouseclick while in mid air.

I have the following code installed for it, but it doesn't seem to affect anything on the fill area of the slider. Hope I'm explaining myself correctly now ;-) I'ts hard to explain without showing the project. :-0

     void DisablePowerBarFillIn$$anonymous$$idAir ()
     {
         if (isGrounded == false) {
             powerBar.enabled = false;
         }
     }

I also tried powerBar.interactable = false; but doesn't work either.

avatar image ArmanDoesStuff Jojoba007 · Feb 19, 2017 at 01:05 PM 0
Share

Have you tried putting the "if (isGrounded == true)" on the mouse click ins$$anonymous$$d?

Again, I'm just assu$$anonymous$$g what your code is but maybe something like:

 void Update()
 {
     if (Input.GetAxis("jump") && isGrounded == true)
     {
         //increase jump slider
     }
 }
 

Show more comments
avatar image
0

Answer by ArmanDoesStuff · Feb 16, 2017 at 10:50 AM

 powerBar.SetActive(false);
Comment
Add comment · Show 2 · 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 Jojoba007 · Feb 16, 2017 at 12:17 PM 0
Share

@ArmanDoesStuff I'm getting the following error: 'UnityEngine.UI.Slider' does not contain a definition for 'SetActive'.

I did get the component: powerBar = GameObject.Find ("Power Bar").GetComponent();

??

avatar image ArmanDoesStuff Jojoba007 · Feb 16, 2017 at 08:45 PM 0
Share

SetActive is under GameObject. So if you want to deactivate something via script you have to deactivate what it's attached to.

For example:

 Slider powerBar = GameObject.Find("Power Bar");
 powerBar.GameObject.SetActive(false);

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

93 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 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 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 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 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 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 avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Buttons: How to enable, disable and enable same button again? 1 Answer

Slider to disable Augmented Reality,Slider Script, Disable script camera 0 Answers

Selectively enable and disable Gamepads?,D 0 Answers

Slider que desactive script en la camara 0 Answers

Im trying to create a crash bandicoot spin but how do i make it disabled after a second? 2 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