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 lordlycastle · Apr 01, 2015 at 07:21 PM · c#bugif-statements

Unity/Mono Develop Bug

I just noticed a bug, but I don’t know if it’s Unity’s faults or Mono Develop’s. I have the following code

 if (!state.wasGroundedLastFrame && _speed.y > 0){
     _newPosition.y += _speed.y * Time.deltaTime;            
 }

Simple enough, but when I was debugging I noticed that it was entering the statement even when _speed.y value was less than 0. See the screenshot below Bug

See that I’m in the statement even thought the y value is -0.43. Can someone else do something similar and report back, this seems like a huge bug, so I’m asking you guys to check it out before I report it.

screen-shot-2015-04-01-at-201348.png (47.2 kB)
Comment
Add comment · Show 4
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 troien · Apr 01, 2015 at 08:00 PM 0
Share

I never used monodevelop to debug (I usually work with Debug.Log). But doesn't the red dot indicate where you 'paused'? In which case it would make sense that the value could be anything sinse it didn't enter the if statement (yet) and is just checking whether to enter the if or not.

I think that you should place that breakpoint (red dot) on line 184 ins$$anonymous$$d of line 183 for it to have the result you expect...

If I'm wrong, please tell me :D

avatar image sumeeton · Apr 01, 2015 at 08:49 PM 0
Share

Your breakpoint is at 183 where the if statement is. The value of _speed.y in the Watch panel is before this if statement is executed. In the debug, move to the next statement 184 and see if the value for _speed.y is greater than 0. That'd mean that the value is getting changed somewhere.

avatar image lordlycastle · Apr 04, 2015 at 06:32 PM 0
Share

@sumeeton @troien The shown value is inside the if block, see the yellow marker on the left. That’s the current line. I stopped at the condition (line 183) and the value is the same as it is in line 184. You don’t have to create new breakpoints for every line, you can just use the “Step Over” button to move line by line.

avatar image sumeeton · Apr 04, 2015 at 07:27 PM 0
Share

Don't know what's really happening. $$anonymous$$aybe you could try this and see if it works.

 if (!state.wasGroundedLastFrame)
 {
      if (_speed.y > 0)
      {
           _newPosition.y += _speed.y * Time.deltaTime;
      }
 }

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by mcapousek · Apr 02, 2015 at 12:29 PM

One cause of such behaviour could be that you added another condition (here: _speed.y > 0) to already existing 'if' but Unity, for unknown reason, didn't recompile this script and you were debuging "previous" state. So to make sure... remove all your breakepoints, close Unity, open it again, do some modification in this script to trigger recompilation a try to debug it again.

Comment
Add comment · 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

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

22 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

Related Questions

Pick up script goes straight to drop action 0 Answers

Multiple Cars not working 1 Answer

Distribute terrain in zones 3 Answers

Items not destroying. 1 Answer

Unity Build Showing Black Screen on Startup Using Oculus SDK 0 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