Function variable problem.

Hey!

I have a strange problem with the code below:

The rotateSpeed variable does not affect the speed of rotation. But if I remove the variable from the Update function and just put a number there, the rotation speed is affected. Can anyone see what the problem is?

Cheers!

var rotateSpeed : float = 35;

 // Interpolate from "from" to "to" with a fixed speed (in degrees per second).
function InterpQuaternionTo( from : Quaternion, to : Quaternion, speed : float ) : Quaternion
{
   var dist = Quaternion.Angle(to, from);
   var maxStepSize = speed * Time.deltaTime;

   if (dist > maxStepSize)
   {
       return Quaternion.Lerp( from, to, maxStepSize / dist );
   }
   else
   {
      return to;
   }
}

function Update()
{
       transform.localRotation = InterpQuaternionTo(transform.localRotation, targetOrientation, rotateSpeed);
}

If you do that and put it on a script that's attached to a prefab, the value that it's going to use for your member variable is the one that's stored on the prefab.

If you want it to solely be based on script and not from the prefab data, declare it to be `private`. Or change it on the prefab.