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 CYVISUALEFFECTS · May 14, 2013 at 04:33 PM · booleanjava

Programming noob help

I am a very beginner with java. I am mmessed up with if and true/false. How to make this look correct? (That's not the whole script)

 function Start(){
     if (gotKey) = false);{
         defaultRot = transform.eulerAngles;
         openRot = new Vector3 (defaultRot.x, defaultRot.y + DoorOpenAngle, defaultRot.z);
Comment
Add comment · Show 1
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 ExTheSea · May 16, 2013 at 03:51 PM 0
Share

Is your problem solved? If so please accept the right answer.

1 Reply

· Add your reply
  • Sort: 
avatar image
0
Best Answer

Answer by ExTheSea · May 14, 2013 at 04:46 PM

Look at this line:

   if (gotKey) = false);{

You have a semicolon behind your if also there are some other weird things in ther. It should look like this:

   if (gotKey == false){
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 FLASHDENMARK · May 14, 2013 at 04:56 PM 1
Share

Will that even compile? Since you have one closing bracket more than open brackets?

avatar image ExTheSea · May 14, 2013 at 05:26 PM 0
Share

Oops i just came home from work and didn't even notice the other weird things in there. I edited my answer. Thanks for pointing it out OrangeLightning.

avatar image zombience · May 14, 2013 at 05:39 PM 0
Share
 if(got$$anonymous$$ey){}

is a shorter way to do that. at the end of the day, an if statement just evaluates the contents of the parenthesis and deter$$anonymous$$es if everything adds up to true or false.

so, if you just feed the if statement a boolean (which is already true or false) then you don't even need to make a comparison

avatar image ExTheSea · May 14, 2013 at 05:44 PM 0
Share

That's right but i used the "extended" version because it is closer to his version and it propably looks more clear to someone new to program$$anonymous$$g but yes:

if(got$$anonymous$$ey)[] is the same as if(got$$anonymous$$ey == true)[]

and

if(!got$$anonymous$$ey)[] is the same as if(got$$anonymous$$ey == false)[]

avatar image FLASHDENMARK · May 14, 2013 at 08:42 PM 0
Share

@ExTheSea

No props! :)

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

18 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

Related Questions

Simple Java Script for Opening and Closing a Drawer 1 Answer

Access variables, objects in array in another script? 2 Answers

scripting help needed, load level? 1 Answer

Ladder script not working? 0 Answers

an object seemingly cannot access a value in other. 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