Oh jeez. I never thought I’d be asking questions like this again! Guess its been a little too long since I used Unity. >_< Anyways. I have some fans that I want to rotate around their X axis, but I can’t remember the right script and all the things I try give me errors. Thanks for putting up with me. ;D
-Moldorma
EDIT: Figured it out, but how would I make the rotation start out slow and speed up, then when I release the key start slowing down the rotation. Thanks!
If you’re using physics, I’d recommend a Euler rotation motor. No scripting involved!
Otherwise…
var fanspeed : float = 0.0; //yours was being initialized to an int, which was problem #1
function Update () {
if (Input.GetKey("up")) {
fanspeed += 0.5;
}else{
fanspeed -= 0.2;
}
fanspeed = Mathf.Clamp(fanspeed, 0.0, 200.0); //change 200 to whatever max speed you want them to be set to
transform.Rotate (0, 0, -fanspeed); //it was also only being rotated while the key was held down. this line needs to be outside the if statement completely
}