Need to know where a variable was changed

Hey everyone. I’m having a problem with the gravityScale on one of my objects being set to zero when it shouldn’t be. My code has gone through many changes and at some point, I may have told it to do this when/where I shouldn’t have.

Basically, I have player characters that throw bombs around. When you’re holding (“cooking”) a bomb, it is set to isKinematic = true, but the gravityScale should still be 1. The problem happens when a player dies while cooking a bomb. When a player dies, the first thing that should happen is it checks to see if the player is cooking a bomb. If so, the Drop() function is called on the bomb which, among other things, sets isKinematic to false, so the bomb drops. This all worked until fairly recently, so I don’t know what the heck I messed with. Suddenly, bombs’ gravityScale is set to zero some time after Drop is called (and it is being called, and the gravity scale is even being explicitly being set to 1 within Drop). I’ve done a Ctrl+F for “gravity” in my PlayerController script and my BombScript, and neither of them ever set the bomb’s gravityScale to 0. It must be happening somewhere else. This, I guess, is why changing public variables directly in other scripts can be problematic.

So the question is this: Is there a debug feature that I’m not aware of, that lets you see where a value of an object is being changed?

Thanks in advanced for any suggestions.

Put a break point in the line where you change the iskinematic back to false & step through the code, you can hover the mouse over stuff to see the value being passed through it.

It could also be something like you are destroying an object & then trying to do some code & it never actually gets to do the extra code at that point because you destroyed the thing it relied relied on.

1 Like

Thanks, Ted. I haven’t tried setting break points or really doing any debugging in Monodevelop itself. I’ve just relied on careful placement of debug output or public variables to see what’s going on, and that doesn’t always cut it.