# Rotation problem (447820)

**URL:** https://discussions.unity.com/t/rotation-problem-447820/447820
**Category:** Scripting
**Tags:** Scripting
**Created:** [June 16, 2011, 6:35pm UTC](https://discussions.unity.com/t/rotation-problem-447820/447820 "2011-06-16T18:35:20Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![anon\_39035680](https://avatars.discourse-cdn.com/v4/letter/a/ccd318/32.png) [@anon\_39035680](https://discussions.unity.com/u/anon_39035680)
#### Post date: [June 16, 2011, 6:35pm UTC](https://discussions.unity.com/t/rotation-problem-447820/447820/1 "2011-06-16T18:35:20Z")

</div>

hi, i have a problem of rotation of pendulum,it will rotate 70 degree right and -70 left, m using GUI slider to adjust speed, but the pendulum is rotating very very slow, m attaching script please help…

1st script(GUIBUTTON)

var speedselection;

speedselection = GUI.HorizontalSlider (Rect (550, 45, 100, 30), speedselection, 0.5, 1.5);

(min\_speed=0.5, max\_speed=1.5)

2nd script(pendulum\_rotation)

var angle : float ;

var x : float ;

x = 0.0f;

var i:int=1;

var speed:float;

var time:float;

function Update ()

{

var guibutton:GUIBUTTON = GameObject.Find(“Scene”).GetComponent(GUIBUTTON);

time=guibutton.speedselection;

speed = 70/time;

angle = Time.deltaTime \* speed;

if(x \<= 70 i==1)  
{  
x += angle;  
if ( x\>69)  
{  
i =-1;  
}  
transform.Rotate (0,angle, 0 );

}  
else if(x \>= -70 i== -1)  
{  
x -= angle;  
if ( x \< -69)  
{  
i =1;  
}  
transform.Rotate (0,-angle,0);  
}  
}

m getting this error “transform.localRotation assign attempt for ‘Cube’ is not valid. Input localRotation is { NaN, NaN, NaN, NaN }” in line “transform.rotate(0,angle,0)”

value of x will be NaN in the inspector… i dont knw wht to do next, please help

---

<div class="post-metadata">

### Author: ![ZigZarc](https://dub1.discourse-cdn.com/unity/user_avatar/discussions.unity.com/zigzarc/32/1002609_2.png) [@ZigZarc](https://discussions.unity.com/u/ZigZarc)
#### Post date: [June 16, 2011, 6:49pm UTC](https://discussions.unity.com/t/rotation-problem-447820/447820/2 "2011-06-16T18:49:21Z")

</div>

Can you format your post so that it is easier to read? Use the code tags available if you “Go Advanced” to separate out which is code.

---

<div class="post-metadata">

### Author: ![anon\_39035680](https://avatars.discourse-cdn.com/v4/letter/a/ccd318/32.png) [@anon\_39035680](https://discussions.unity.com/u/anon_39035680)
#### Post date: [June 16, 2011, 6:50pm UTC](https://discussions.unity.com/t/rotation-problem-447820/447820/3 "2011-06-16T18:50:36Z")

</div>

var angle : float ;

var x : float ;

x = 0.0f;

var i:int=1;

var speed:float;

var time:float;

function Update ()

{

var guibutton:GUIBUTTON = GameObject.Find(“Scene”).GetComponent(GUIBUTTON);

time=guibutton.speedselection;

speed = 70/time;

angle = Time.deltaTime \* speed;

if(x \<= 70 i==1)  
{  
x += angle;  
if ( x\>69)  
{  
i =-1;  
}  
transform.Rotate (0,angle, 0 );

}  
else if(x \>= -70 i== -1)  
{  
x -= angle;  
if ( x \< -69)  
{  
i =1;  
}  
transform.Rotate (0,-angle,0);  
}  
}

---

<div class="post-metadata">

### Author: ![ivkoni](https://dub1.discourse-cdn.com/unity/user_avatar/discussions.unity.com/ivkoni/32/320785_2.png) [@ivkoni](https://discussions.unity.com/u/ivkoni)
#### Post date: [June 16, 2011, 6:54pm UTC](https://discussions.unity.com/t/rotation-problem-447820/447820/4 "2011-06-16T18:54:10Z")

</div>

much better 🙂

---

<div class="post-metadata">

### Author: ![j\_y\_k](https://avatars.discourse-cdn.com/v4/letter/j/71c47a/32.png) [@j\_y\_k](https://discussions.unity.com/u/j_y_k)
#### Post date: [June 16, 2011, 9:55pm UTC](https://discussions.unity.com/t/rotation-problem-447820/447820/5 "2011-06-16T21:55:58Z")

</div>

@The OP: It looks like the tags are still incorrect. You can apply the tags in the editor, or enter them manually by typing [code] (without the spaces), pasting the code, and then typing [/code] (without the spaces). You should then get something like this:

```auto
function foo()
{
}

```

(Another tip: Replacing all hard tabs with spaces before pasting in code will increase the chances of the formatting being preserved correctly.)
