Avoiding certain console output


I have a method with the following line in my Update() method of my main script:

transform.rotation = Quaternion.LookRotation(rigidbody.velocity);

Now, sometimes rigidbody.volicity is a zero vector - a problem that I will be fixing later - and whenever it is a zero vector, my console output comes out to:

This is driving me nuts because it gets in the way of Debug.Log.

Now, I could put an if-statement such that the line doesnt get reached when rigidbody.volicity.magnitude is zero, but there must be a simpler way of doing this…

Or is this the only way?


The conditional is the best way. There’s no sense in setting a vector when there’s no semantic meaning to doing so.

Alternatively, if you just want to be able to see different log messages, try the Collapse option on your console - it will condense down duplicates of the same message, so instead of seeing a huge list, you’ll see just one of them, followed by the number of times it occurred.

I still recommend the former, though.