- Home /
"ref float" is not compatible with the argument list "float"
I'm really drawing a blank as to why this is happening.
var angle: float = Vector3.Angle(v1,v2); transform.rotation.ToAngleAxis(angle,Vector3.up );
I get this error
The best overload for the method 'UnityEngine.Quaternion.ToAngleAxis(ref float, ref UnityEngine.Vector3)' is not compatible with the argument list '(float, UnityEngine.Vector3)'.
Someone told me "ref passes a reference rather than a copy, so var changes in the function propagate to caller scope" but I am not grasping the problem and how to fix this.
Any help would be appreciated!
Answer by Dave-Carlile · Apr 27, 2013 at 04:09 PM
I believe the issue may be that you're passing Vector3.up
as the vector. That is a system value and cannot be changed. Try this...
Vector3 up = Vector3.up;
transform.rotation.ToAngleAxis(angle, up);
If you're using C#, you also have to specify that the parameters are output parameters when you call the function...
transform.rotation.ToAngleAxis(out angle, out up);
yes, although, in this case, it is 'ref' ins$$anonymous$$d of 'out' :)
Oh my word it was the Vector3.up? And here I was trying a million and 1 things on the float, strange why this has never happened to me before.
Thank you so much for your help!
Your answer
Follow this Question
Related Questions
Raycasting at an offset angle? 4 Answers
Angle Between vectors in Navigation Mesh 1 Answer
problem with vector3.Angle with a fixed joint 2 Answers
Get the signed angle between 2 two Vector3 1 Answer
Snapping to Object Forward Axis 0 Answers