I recently got into Unity mostly for working with audio. I’ve used another engine but never this one before now (I like it quite a bit and already have a new project with a group I belong to). I was doing some work in the sewer demo for some initial practice, and finished everything to the point of adding footsteps for different materials, etc, and in fact this is not a problem. My problem is this:
I wanted to make the FPS Walker move slower, just a bit, to see how it felt.
The speed variable as shown in the inspector didn’t have an effect, so I changed the script. It was slower than I wanted, and now I’m stuck with it; no alteration has any effect on the speed. It’s now back to what seems to be the standard of 6, but still moves slow.
Any idea what I did, or if it can be fixed? I wouldn’t have expected this to have a permanent change, but maybe I missed something I should have read. Thanks in advance for any ideas; I hope this is a stupid question.
The speed variable in the inspector is the only one that has any effect; it always overrides whatever might be in the script.
–Eric
Well, if that’s the case, I hit some kind of bug, because it definitely wasn’t working properly. Only editing the script changed anything, and even then only once. The inspector variable still won’t work when I run this scene, I just tried.
Luckily, I had a backup of this I had forgotten about at the time of writing the post, so it’s not so dire. Still, it makes me worry about things like that happening in the future. Ah well.
You might have been changing the value on the prefab, rather than the object in the scene. Also be aware that inspector variables altered in play mode will revert when play is stopped.
Actually there is one case in which changing the script will override the inspector, which is if you change the type of the variable (like from a float to an int). In this case the value will change to whatever’s defined in the script, although the inspector will then always take precedence afterward, unless you change the type again.
–Eric
Ah! That’s what I did; I must have change the type, and it set the object in the scene to something else, then I kept trying to fix it with the prefab. Or something like that. Anyway, thanks a lot for explaining more on that; I may have kept making that mistake otherwise.
Obviously, you can change the value (for example speed=20;) inside the Update function and logically it will override the inspector’s value. 