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 emir3100 · Jan 11, 2017 at 11:55 PM · setactiveif statementgetkeydownbooleans

Other way to write a code

for some reason when I put this code in the update function it will not work is there a other way to write this code?

     if(canIncrease && notFullHealth == false && Input.GetKeyDown(KeyCode.G))
     {
         Atext();
     }
Comment
Add comment · Show 7
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 Scoutas · Jan 12, 2017 at 12:18 AM 1
Share

I'd say, first of all, do a Debug.Log into the console, for the canIncrease , notFullHealth and Input.Get$$anonymous$$eyDown($$anonymous$$eyCode.G) variables and see if they are all right.

Put this before the if statement:

Debug.Log("canIncrease: " + canIncrease + " | notFullHealth: " + notFullHealth + " | Input: " + Input.Get$$anonymous$$eyDown($$anonymous$$eyCode.G))

And then look in the console, if you ever get

"canIncrease: true | notFullHealth: false | Input: true"

avatar image emir3100 Scoutas · Jan 12, 2017 at 07:59 PM 0
Share

Yes I get them except for the input: true its stays at false.

avatar image emir3100 Scoutas · Jan 12, 2017 at 08:07 PM 0
Share

never $$anonymous$$d i fixed the problem but thanks anyway

avatar image whynot660 · Jan 12, 2017 at 08:09 PM 0
Share

are you sure because every thing looks fine, even if I prefer it better with brackets just check that its void Update() not void update()

avatar image hexagonius · Jan 12, 2017 at 09:49 PM 0
Share

one improvement:

 notFullHealth == false
 ==
 !notFullHealth
avatar image Pengocat hexagonius · Jan 12, 2017 at 10:08 PM 0
Share

When reading the code I would prefer the first option. The second option would be read as a double negative "not not Full Health" vs "not Full health equals false".

avatar image hexagonius Pengocat · Jan 14, 2017 at 01:44 PM 0
Share

thats correct. But you usually name your bool after the true state, and then you'd use the exclamation mark

0 Replies

· Add your reply
  • Sort: 

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

90 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

Related Questions

trouble switching between booleans 2 Answers

Unity Update is ignoring the GetKey part of my statement!? 2 Answers

How to make a gameObject appear when I press spacebar down? 1 Answer

can you set boolean values using the input.getkeydown(keycode.(key)) 1 Answer

How do you wait for key press before a game starts? 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