How can i decrease angle every in simple pendulum in my project?

Hi All,

please take a look of this question.
http://answers.unity3d.com/questions/422829/how-can-a-decrease-angle-every-time-in-simple-pend.html

and answer me . I posted that question before and also i tried so many times but that is not done at. that is the final task for me then only my project is completed. Please help me.

Thanks
To all.

That’s a big hunk of code, without a lot of explaining. Does it swing back and forth in a half circle, and you want to decrease that? Or do you want to change what clicking the mouse does (in that OnMouse* area)?

If you read it some, there are a lot of lines like if(x>90), if(z<270) and such. Those are probably checking if you went past some angle. Read more what they do (what part of the code says “now start moving the other way”?) Then maybe just change some numbers and see what happens.

And, very common in games, sometimes what you wanted to do isn’t fun, looks bad, has unsolvable problems. So you just drop it, but you learned and maybe it gave you an idea for something else.

I’m assuming you want the pendulum to run down due to friction? I can think of two ways of handling this issue. If you really want to only adjust the angles once per cycle, then detect when ‘f’ transitions across .5. That is keep a copy of f from the previous fame (or a boolean value) , and when f was less than 0.5 in the previous frame and is now greater than or equal to .5, you can decrease the angle. If you want to decrease it going both directions, then add a second check for when f is greater than or equal to and transitions to less than .5.

A second method would be to go ahead and reduce the angle every frame, but by an amount that is scaled so that the reduction of the angle across a full cycle is the same as the single reduction you would make in the method above.

Note that angle1 and angle2 are not normalized. That is, angle1 may start in any quadrant, and angle2 reflected. Without more study, I cannot be sure, but I think you want to reduce the angle towards the average between angle1 and angle2.