Quick Question About UnityScript

Is there an easier way to say this?

Vector3(transform.position.x,transform.position.y,transform.position.z-.5)

thanks!

in uJS :

var pos : Vector3 = transform.position;
pos = pos + Vector3( 0, 0, -0.5 );

or :

var pos : Vector3 = transform.position;
pos += Vector3( 0, 0, -0.5 );

or :

var newPos : Vector3 = transform.position + Vector3( 0, 0, -0.5 );

in C# :

Vector3 pos = transform.position;
pos = pos + new Vector3( 0, 0, -0.5 );

as I don’t use C#, I am not sure if you can shorten that line to

pos += new Vector3( 0, 0, -0.5 );

but try it out.

or something else to try (this is probably the one you are after) :

Vector3 newPos = transform.position + new Vector3( 0, 0, -0.5 );

For doing what? Probably you can just use transform.position because this is already a Vector3 object.

Actually I don’t think so. Maybe you can store those values inside a Transform variable. It would make that one line shorter but you would still spend the time writing the variables. Those are your only options sorry about that!

It depends on what you are trying to do:

Move your object 0.5 units on the negative Z axis:

transform.position.z -= .5;

Perhaps you need to do this on its local axis again depending on what your goal is:

transform.localPosition.z -= .5;