Okay i have this code here
I assign speed to the Get axis stuff in awake but when i use debug log (speed) in update it doesnt keep changing when i move my mouse… is it because speed only equals that one value it was set to in awake and it will not update itself, meaning it doesnt have a reference connection to the getAxis code?
which would mean i have to put that assignment in update, but would it be bad coding to create an assignment again every frame?
#pragma strict
var acolors : GameObject[ ];
private var color : GameObject;
private var mousePos : Vector3;
private var worldPos : Vector3;
private var started : boolean = false;
private var speed : float;
function Awake () {
speed = Mathf.Abs(Input.GetAxis(“Mouse X”)) +
Mathf.Abs(Input.GetAxis(“Mouse Y”));
color = acolors[Random.Range(0,acolors.Length)];
}
function Update () {
//Debug.Log(Mathf.Abs(Input.GetAxis(“Mouse X”)) +
//Mathf.Abs(Input.GetAxis(“Mouse Y”)));
Debug.Log(speed);
if(Input.GetMouseButton(0)) {
mousePos = Input.mousePosition;
mousePos.z = 1.5;
worldPos = camera.ScreenToWorldPoint(mousePos);
Instantiate(color,worldPos,Quaternion.identity);
if(!started) {
StartCoroutine(“colorchange”);
}
}
}