O'Reilly logo

Unity 3 Game Development HOTSHOT by Jate Wittayabundit

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Changing Struct properties by value VS by reference

Structures are passed by value in C#, so you cannot change the x or y value of a Vector3 and you need to create a new Vector3 and assign it to the Vector3 that you want. However, in JavaScript, you can write it as follows.

JavaScript:

transform.position.x = 1;

C#:

transform.position = new Vector3(1, transform.position.y, transform.position.z);

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required