I created a simple JavaScript to move an object around in 2D space.
#pragma strict
var speed : float = 10.0;
function Update()
{
Debug.Log(speed);
// Map player movement to the directional keys.
var moveX : float = speed * Input.GetAxis("Horizontal") * Time.deltaTime;
var moveY : float = speed * Input.GetAxis("Vertical") * Time.deltaTime;
transform.Translate(moveX, 0, 0);
transform.Translate(0, moveY, 0);
}
I noticed that changing the speed variable did not change the object’s movement speed whatsoever, so I added the Debug.Log() statement. I found that the during the first run, the console would print out the value of 10, but when I change the speed variable to something else, say 20, the value that the console outputs stays at 10. However, when I move speed into the Update function, the console would output the correct value of speed.
Is this a bug?