Relying on (just) declared vars before Start, Awake, update etc?

Ok I really do not know how to make a search on this.

I want to declare some Vector3’s for my Script, but they all should share the same Z variable (So later, I can easily move the whole “thing” forward / backwards).

Is it OK to write code like this?

#pragma strict

var test : float = 10.55;

private var somePositionFL = Vector3(-0.8, test, 1.1);
private var someOtherPos = Vector3(-0.2, test, 1.9);

function Awake () {
 //empty in this case
}

function Start () {
 //empty in this case
}

There are NO errors from the compiler. But it looks so wrong :confused:
Thank you!! Dennis

It’s just a matter of point of view.

In my games I’d do something like :

var test : float = 10.55;
 
private var somePositionFL;
private var someOtherPos;
 
function Awake () {
  somePositionFL = Vector3(-0.8, test, 1.1);
  someOtherPos = Vector3(-0.2, test, 1.9);
}

I find it more pleasant than what you propose. But once again every developers make ugly things and “ugly” is just a matter of point of view.

BTW: in your question you say that your vector must have the same Z but your variable is applied to Y value.