I occasionally saw some jerkiness in the craft in my anti-gravity racing game. I was having a horrible time tracking it down, since whenever I actually focused on it, it seemed to disappear. Weird. :?
However, it started doing it again recently, but this time I had it. I undid/redid the last change in my script and found the problem: Debug.Log.
What :shock: ? A debug statement causes my craft to go berserk!? :x Oh, but wait, It gets better . Today I was working on a another problem (which will be in another post :roll: ) and the problem showed up when I changed a variable while playing it that resides in a block of code that clearly wasn’t executing.
Please tell me I’m not crazy
It’s kind of hard to say anything for sure without seeing your code. Most likely is that something inside your Debug.Log statement was inadvertently changing something (a function call, for example). I couldn’t quite parse what you’re trying to say in your second problem so I can’t really figure out how to help you
Nope.
Debug.Log(rigidbody.velocity.magnitude);
I think that was the one that did it, I tried several different things to isolate a calculation issue, that was one of them.
And, my bad. Take two:
The problem showed up when I changed a variable while playing the game. The variable resides in an OnTriggerStay function that also changes the color of the object, and it clearly wasn’t changing.
I think I just have to call this a freak occurrence and just make sure the final version doesn’t do it. Maybe the docs wern’t kidding when they said Vector3.magnitude is far more intensive then Vector3.sqrmagnitude…
:?
With that debug statement, you are doing both a square root (magnitude) and logging to the console. If you are doing this every frame, or worse, multiple times per frame, this can seriously kill your framerate.
It’s likely that the first problem you had was caused by all the logging going on.
-Jeremy
That would bog it down, but the jerkiness is back with a vengeance despite the removal of the offending code. I think there’s something wrong with the craft itself, but it’s subtle…
A good debugger would help. Anyone got a can of bugspray? :lol: