Can anyone explain why this script isn’t changing the variable Speed?
public var Speed: float;
function Update (){
var Speed : float = Input.GetAxis("Mouse ScrollWheel");
}
Can anyone explain why this script isn’t changing the variable Speed?
public var Speed: float;
function Update (){
var Speed : float = Input.GetAxis("Mouse ScrollWheel");
}
This line:
var Speed : float = Input.GetAxis("Mouse ScrollWheel");
Should read:
Speed = Input.GetAxis("Mouse ScrollWheel");
Your mistake is that you’re declaring a new variable “Speed” that exists only within the Update
function. Changes made inside that scope don’t affect the original variable.
Remove the var
declaration, and you’ll be using the original variable.