Hi Daisy,
Since Vector3 is a value type, I believe a *copy* of the "_position" is
actually returned. Since there is no sense in modifying the copy - it won't
be persisted anywhere - the compiler gives you the error in question.
You should introduce a method like Move(xOffset, yOffset, zOffset) or
MoveX(offset) instead, or indeed switch to a reference type to store the
position. The latter approach, however, is more error prone as you have no
control on how and when the object position is modified.
--
Dmitriy Lapshin [C# / .NET MVP]
X-Unity Test Studio
http://x-unity.miik.com.ua/teststudio.aspx
Bring the power of unit testing to VS .NET IDE
"Daisy" <da***@nospam.oops> wrote in message
news:on***************@newsfep4-winn.server.ntli.net...
I came across this problem at work, and now at home... I've got an object
that stores its position in a Vector3 object.
Looks like this:
public class Object3D
{
Vector3 _position;
public Vector3 Position
{
get { return _position; }
}
}
But when I try setting a field, like this:
Object3D dan = new Object3D();
dan.Position.X = 10;
I get the error in the subject, because a Vector3 is a value type.
Given I might just want to increase the X position, is there any way I can
change this value, without setting it to a new Vector3 and passing the
other two fields back in?
--
Daisy The Cow
Now playing: Toploader - Time Of My Life