Impossible Zero viewing vector...

Somehow this bit of code:

		if (birdPhysicsHandler.relativeCameraPosition.sqrMagnitude != 0  vectorTargetPosition.sqrMagnitude != 0) {
			dragVectorGraphic.rotation = Quaternion.LookRotation(vectorTargetPosition,
			                                                     birdPhysicsHandler.relativeCameraPosition);
		}

is giving me this error:

Look rotation viewing vector is zero
UnityEngine.Quaternion:LookRotation(Vector3, Vector3)

How is that even possible? That code should only run if the values are NOT zero?

You probably are passing in the same vector for forward and up. making the cross product mag zero.

is vectorTargetPosition is a position? it should be a delta ( as in the vector from a to b )

the second parameter is the up direction. which basically works like the roll around the first parameter.

Yes, vectorTargetPosition is a delta position. My up direction vector is is the delta from ‘a’ to the main camera.

Are you saying that the up vector should actually be the delta from b to the main camera?

Also, from what I understood of what you said, I’d essentially get that error if ‘a’ was the same direction as the camera?

So I tried doing this:

if (vectorTargetPosition.normalized != birdPhysicsHandler.relativeCameraPosition.normalized) {
			dragVectorGraphic.rotation = Quaternion.LookRotation(vectorTargetPosition,
			                                                     birdPhysicsHandler.relativeCameraPosition);
		}

but still got the same error. Weird.

No the up vector should be like the way up should face. If your unsure try just using Vector3.up or Vector3.forward to see how it works.

look and up vectors cannot be the same or opposite of eachother. They need to be non parallel in direction.

I know this is a sucky response but try printing the values sent to LookRotation before calling it. Then when the zero vector error happens, see what the values were manually in the log

Yeah, I tried printing out the vectors and was getting non-zero vectors. Also, as my code snippets above show, it shouldn’t even be running LookRotation() unless they are non-zero vectors or, in the case of the second example, if they are not equal.

In my game, there is no condition during which they would be opposite, and I have tried testing that as well, yet still the conditionals pass as true.

Basically, the first vector points in the direction of the wind in the game (which is moving pretty much perpendicular to the camera’s forward), and the second vector points from the object to the camera.