- Home /
Cant slow down rotation Speed
var horizontal :float;
var curhorizontal:float;
var vertical:float;
var curvertical:float;
var turnspeed:float=0.02;
function Update () {
if (networkView.isMine){
horizontal=Input.GetAxis("H")*turnspeed*Time.deltaTime;
curhorizontal = Mathf.Lerp(curhorizontal,horizontal,Time.deltaTime);
vertical=turnspeed*Input.GetAxis("V")*Time.deltaTime;
curvertical = Mathf.Lerp(curvertical,vertical,Time.deltaTime);
transform.Rotate(vertical,horizontal,0);
}
}
Hi, since a few days i try to regulate the rotiation Speed of diffrent Player Controllers.
In this Script, it dosnt matter what value "turnspeed" have, the Objekt rotate at the same speed.
Can anyone Help my out?
Since this turnspeed is public, the value is the script will only be used when the script is attached to the game object. Changes in the script after that will be ignored. As @Trond suggest, make the change in the inspector. Or you can make the variable private:
private var turnspeed:float = 0.02;
The variable will no longer appear in the inspector.
Answer by Trond · May 05, 2013 at 03:00 PM
Im not sure, but i guess that the inspector might overwright the "turnspeed". The inspector do sometimes take the first value a variable was set to and keeps it(atleast used to in earlier versions of unity). Therfore, trying to set a value for the variable where you define it might be a bad idea. You should instead try to change "turnspeed" in the inspector, OR set the value in Awake() or Start() like so:
function Start(){
turnspeed = 0.02;
}