- Home /
Answer by Drakulo · Jan 21, 2014 at 11:12 AM
There is no difference, the two snippets do the same thing. However, reusing existing objects is better, especially in loops because it's expensive.
Your answer is a bit misleading. Vectors are structs (not objects), so no allocations is made on the heap.
Yes, people should simply forget that the Set method actually exists. It's just the cause of many issues. I'm not sure why they actually implemented it. We had countless questions why this doesn't work:
// THIS DOESN'T WORK
transform.position.Set(1,2,3);
but this does work:
transform.position = new Vector3(1,2,3);
While mutable structs on their own aren't really an issue, the combination with other concepts are. In this case the access through a property.