- Home /
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
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.
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
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.
@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.
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;
}
}
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.
Your answer

Follow this Question
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