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 sourabhd · Jan 23, 2013 at 07:41 PM · errorbeginnernoobsyntax

Greater than and less than syntax problem

So I both of these in the Update function for the same script

 if (slowMoMeter < 0 )    {
 
     slowMoMeter=0;
     
     }
 
 if (slowMoState==true)    {
 
     if ( slowMoMeter > (Time.time- startTimer))    {
     
     slowMoState1=true;
     
     }

The code above doesn't work. When I investigated, I found that whenever I put my cursor next to one of the greater than or less than signs, it highlighted the other one. much like it would do for paired brackets or parenthesis. I don't want them to be paired, I just want them to be simple greater than and less than signs! Totally noob question but Please help!

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 Jessy · Jan 23, 2013 at 07:51 PM 0
Share

Your braces don't match. are irrelevant.

avatar image Dave-Carlile · Jan 23, 2013 at 07:52 PM 0
Share

Doesn't work how? Compiler error? Runtime error?

avatar image save · Jan 23, 2013 at 07:55 PM 0
Share

I have no idea how this is connected to greater than and less than and your cursor, are you sure that is your issue?

To help you further we need to know this: What makes slow$$anonymous$$oState true? How do you increase slow$$anonymous$$o$$anonymous$$eter? Where do you set startTimer? Do you have an end curly brace to if (slow$$anonymous$$oState)?

Other than that, Jessy probably has the correct answer to your problem.

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by sarith · Jan 23, 2013 at 07:59 PM

Looks like you're just missing a closing curly brace "}" for your second if statement. This should work:

 if (slowMoMeter < 0 ) {
     slowMoMeter = 0;
 }
 
 if (slowMoState == true) {
     if (slowMoMeter > (Time.time - startTimer)) {
         slowMoState1 = true;
     }
 }


Also, you could refactor a bit as follows:

 if (slowMoMeter < 0 ) {
     slowMoMeter = 0;
 }
 
 if (slowMoState && (slowMoMeter > (Time.time - startTimer))) {
         slowMoState1 = true;
 }
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 Wolfram · Jan 23, 2013 at 08:04 PM 0
Share

He could even pack an "else" between these if's ;-)

avatar image sarith · Jan 23, 2013 at 10:42 PM 0
Share

I'm pretty sure they're unrelated conditionals -- but yes, if they're related, you can replace that second if statement with an else or if else

avatar image Wolfram · Jan 23, 2013 at 10:48 PM 0
Share

Relation doesn't matter. This particular second if will never be true if slow$$anonymous$$o$$anonymous$$eter is

avatar image sarith · Jan 23, 2013 at 10:50 PM 0
Share

Oh! haha -- sorry i didn't even look back at the code. #dumb

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

14 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

Related Questions

Disable function OnTriggerExit? 2 Answers

BEGINNER: why is my main menu not loading level 1 when I press play? 1 Answer

my prefab images dont appear in my scene view but are in my camera view 2 Answers

Enter Trigger, display Text, then delete object 1 Answer

Basic javascript array declaration 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