Content does not change

Hi
I assigend the FPSWalker script to a cube…
then I edit the script to

var speed = 600.0;
var jumpSpeed = 800.0;

just as an test… then I save and close the edit window…
but in the insepctor is still the old code and the “normal” behavior…?

var speed = 6.0;
var jumpSpeed = 8.0;

is this normal??

by the way… if i write a new script and edit the code I see this code never in the inspector. therefor i have to edit it…


ah I figured out that I have to reimport it…
but why does the speed not change?
does it not matter if the speed is set to 6.0 or 600.0???

It’s not quite clear what you’re saying but I think I understand. To clarify, you write in the script:

var speed = 600.0;

You sve and go into the editor, and “speed” pops up with a value of 600. You then edit the script again to:

var speed = 6.0;

And it still says 600 in the inspector. Is this what you’re talking about?

This is the expected behaviour. Think of the values you write in the script as the “default” value. However, once it’s got a value in the inspector, once it “exists”, that value is pretty much ignored.

(If you think about it, letting the in-script value override the inspector value would be Very Bad. Any script value you change, ever, would be overridden every time Unity recompiled scripts.)

If you make the var private, it will change when you change it in the script.

?

I test this script:

var speed = 5.0;
function Update () {
var x = Input.GetAxis(“Horizontal”) * Time.deltaTime * speed;
var z = Input.GetAxis(“Vertical”) * Time.deltaTime * speed;
transform.Translate(x, 0, z);
}

and the speed of the box does not change if I change the speed var to 5000.0???


ah… now I got it… today it is working… :slight_smile:
perhaps is Unity for windows just a little bit to buggy… get often crashes… I did the same as yesterday… now it is working :slight_smile:

As StarManta said, the values you set in the inspector override any values you set through code.

yes, i got it now… didnt see that I can change the value in the inspector :slight_smile: