how can i set angle to zero in the pendulum?

Hi All,

By using this link Motion script for simple pendulum? - Questions & Answers - Unity Discussions i implemented simple pendulum in that bydefault pendulum is in start position. I don’t know why that is happening.
My requirement is when ever we drag that pendulum depended on that drag angle than motion will be coming. and also can any one tell me how can i implement t=2pisqureroot(l/g) in that.
Please help me.
thanks to all

I’m not sure what you are seeing. For this code to work, you have to your situation setup correctly. When the pivot point is has rotation (0,0,0), the pendulum should be point to the right. Angles in Unity start on the positive ‘x’ axis and go counter-clockwise. If you want a different starting angle when you run the app, change startAngle and endAngle to the two ends of the initial swing.

This is sounding like a class assignment, so I’m reluctant to just code up the answer for you. But there are some things to consider.

Since this code does not use Unity’s physics engine, the size of things is what you make them. So figure out motion that looks right with the model you build and then work backwards. Figure out the frequency, then you can use this equation to figure out the initial length and scale other lengths (I’m assuming you want to demonstrate) to match:

length = g/(4*PI*freq^2)

When I wrote this code, I did not look at the pendulum equations. I just said this looks sinusoidal, and stuck a some values in until it behaved correctly. All that logic is contained in this line:

float f = (Mathf.Sin (fTimer * speed - Mathf.PI / 2.0f) + 1.0f) / 2.0f ; 

You might have a easier time if you recode this to match the actual equation. From Wikipedia:

9057-pendulumperiod.png