I’m not entirely sure how to ask this question, as I have no idea whats going on here but I’m going to do my best to explain, hopefully someone can chime in and inform me whats happening here!
Problem: Float_x - Float_x != 0
I have 2 float values. One float is declared in the beginning of the script like so:
float float_x = -127f;
The other float is taken from an instance of another script, and this seems to directly correlate with the issue. We’ll call this float_y, and float_y is a y value from a Vector2.
IF the float is the same, I get an incorrect result and this message in the console: Look rotation viewing vector is zero (this is just a message not an error or warning) which is strange because I’m not attempting to rotate anything…
example output: float_x - float_y = -7.629395E-06.
It cannot simply be float precision issues, I am not even using any decimal places (same result when I do though).
if float_y is set to any value other than the same value as float_x, it returns the proper result and no error. It simply does not want to equal 0.
edit: still receiving this Look rotation viewing vector is zero message…edit :I found that I get this message when I move the cursor off of the console AND the app is not playing in the editor.
The Look rotation viewing vector is zero means pops when you try to call a rotation method towards a vector zero (0,0,0) so you will have to investigate where this might happen. What are you using your difference for?
The problem is basically kinda like a divide by 0 error… that results in an infinite number of possibilities. In this case you’re trying to set your look rotation towards a vector with no length, which an infinite number of rotations would satisfy…so this error is thrown because Unity is basically saying “we don’t think that we should guess what you want here”. So the solution is to have your own default look rotation (previous rotation, perhaps) for when the value you’re supplying to your LookRotation function is Vector3.zero
example…
if (yourVector3 != Vector3.zero)
{
// do lookrotation with yourVector3 as the param
}
else
{
// do whatever you want it to do instead
}
Edit: @Rotary-Heart … sorry, guess you snuck a reply in just before mine
I am using the difference to plot a point in x,y coordinates using a Vector2. Nothing to do with rotation… (in fact I searched my scripts for any reference to quaternions and rotations, there is nothing in the entire app that is being rotated.) I edited my above post to include a video of the console. It’s very strange behavior. I found that I get this message when I move the cursor off of the console AND the app is not playing in the editor.
However, the code now works correctly, Im just trying to figure out what this deal is with Unity spamming the console…
That’s odd do you have something looking at your mouse? It seems to be related to the mouse coordinates so I would check where in your code you are using the mouse coords