Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by navadeep2011 · Mar 25, 2013 at 09:18 AM · physicsanglemotion

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.

Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

2 Replies

· Add your reply
  • Sort: 
avatar image
0

Answer by Owen-Reynolds · Mar 25, 2013 at 02:53 PM

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.

Comment
Add comment · Show 1 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image navadeep2011 · Mar 26, 2013 at 03:23 AM 0
Share

Hi Owen Reynolds, Thanks for answering my question. In this project is not having lot of code.just one code for On GUI and one code for pendulum control. In this code my main problem is first i drag some angle so that angle is updated to updated method. v3T.Set (0.0f, 0.0f, $$anonymous$$athf.Lerp(startAngle, endAngle, f)); pivot.eulerAngles = v3T; fTimer += Time.deltaTime;

that is in updated method. please take a look. And give me correct answer. please help me. I have struck that problem from last week.

Thanks

avatar image
0

Answer by robertbu · Mar 26, 2013 at 05:07 AM

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.

Comment
Add comment · Show 4 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image navadeep2011 · Mar 26, 2013 at 07:20 AM 0
Share

Thanks for answering $$anonymous$$r Robertbu. I tired above two methods. 1)I wrote code like this

void Update() {

 if (!dragging) {
         if(anglespeed>0 && anglespeed<180)
         {
             length1 = ((anglespeed*2*($$anonymous$$athf.PI)*GUI$$anonymous$$enu.StripeValue)/180);
             speed=length1/Timeperiod;
         }
         else if(anglespeed>180 && anglespeed<=270)
         {
             angles1 = anglespeed-180;
             angles2 = 180-angles1;
             length1 = ((angles2*2*($$anonymous$$athf.PI)*GUI$$anonymous$$enu.StripeValue)/180);
             speed=length1/Timeperiod;
         }
         else if(anglespeed>-90 && anglespeed<0)
         {
             angles1 = anglespeed+90;
             length1 = ((angles1*2*($$anonymous$$athf.PI)*GUI$$anonymous$$enu.StripeValue)/180);
             speed=length1/Timeperiod;
         }
         
 float f = ($$anonymous$$athf.Sin (fTimer * speed - $$anonymous$$athf.PI / 2.0f) + 1.0f) / 2.0f ;
         
  
 v3T.Set (0.0f, 0.0f, $$anonymous$$athf.Lerp(startAngle, endAngle, f));
         
 pivot.eulerAngles = v3T;
 fTimer += Time.deltaTime;
     Timeperiod=(2*($$anonymous$$athf.PI)*($$anonymous$$athf.Sqrt(GUI$$anonymous$$enu.StripeValue/9.81f)))    ;
         Debug.Log(startAngle);
         if(f> 0.5f)
         {
             
             {
                 startAngle +=1;
                 endAngle -=1;
                 anglespeed-=2;
                 
             }
         }
         
 }
 }

But that is not working properly. It is not taking complete cycle. when ever the f >0.5 than it decreases the angle but not going for complete cycle. If possible please modify my update method code.

2) I will now how many frames for a cycle. ? really second one i didn't get you.

Thankyou

avatar image robertbu · Mar 26, 2013 at 12:51 PM 0
Share

You are looking for the transition across the .5. So you have to save and use the value of f from the previous frame. Something like:

 if (f >= 0.5 && fPrev < 0.5) {
     // decrease angles
 }
 fPrev = f;
avatar image navadeep2011 · Mar 26, 2013 at 03:06 PM 0
Share

$$anonymous$$r Robertbu ur really great. Thanks a lot for helping me. $$anonymous$$y project trail version max completed.

can i get a suggestion how will working on force concept in simple pendulum. i mean by using force i want to get p.e and k.e. can i get any idea. than i will implement.

avatar image robertbu · Mar 26, 2013 at 06:17 PM 0
Share

General design questions are really for the forums. When you actually get to the point of implementing your ke/pe, you can post a new quesiton here. If I see it go by I'll be sure to take a look. Note that the code above is based on an answer I wrote awhile back. That answer was never intended to be an accurate physics simulation of a pendulum. I just knew that pendulums were sinosodial, and wrote some code that made the pendulum look right. Since then (given all the questions about pendulums), I've gone back and looked at the equations. I don't know how to what degree you've made changes to mimic the real physics.

Here is one link that writes about PE/$$anonymous$$E of pendulums:

http://www.physicsclassroom.com/mmedia/energy/pe.cfm

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

11 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Motion working not properly in simple pendulum 1 Answer

Calculate the normal of a collider 1 Answer

Calculating a projectiles angle required to hit object. 2 Answers

Player not able to climb an angle 2 Answers

How to find cannon elevation angle to fire a projectile to known range? 1 Answer


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges