I would like to extend a method found in C# XNA which will set the length of a vector.
I thought I should go with extensions as that seemed like the only option. It appears that this isn't going to work as intended as my original vector value isn't updated when using this extension method.
public static Vector2 SetLength(this Vector2 v, float length)
{
v.Normalize();
return v *= length;
}
If I have the line
Vector3 vec = new Vector3(0, 3, 0);
then set the new length using
vec.SetLength(10);
the vec variable does not get updated. Why is this, and what are my alternatives?