- Home /
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); }
Answer by Tetrad · Jul 07, 2010 at 05:08 PM
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.
Thanks! big fail on my part there....ill never forget it now though :-)
Your answer
Follow this Question
Related Questions
Can someone help me fix my Javascript for Flickering Light? 6 Answers
Setting Scroll View Width GUILayout 1 Answer
Set variable/Array to a length by scripting 2 Answers
Get a variable from another file javascipt 1 Answer
Maths with variables 2 Answers