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
1
Question by flamz · Aug 16, 2012 at 01:26 AM · physicsanchorhinge joint

help with simple pendulum simulation

Hello, I am trying to make a simple pendulum setup with Unity's physics system but I am experiencing some bizarre behaviour.

Here's my setup, I have a ball attached to an elongated capsule using a fixed joint. Then, the elongated capsule is attached to a cube using a hinge joint, finally the cube is constrained in the XY and Z axis in both translation and rotation (this is the only I found to make the cube stay fixed).

here's a screenshot to make things clearer:

alt text

and here's a video of the resulting simulation:

link text

all wrong :( ... for some reason, the capsule and ball seem to be attached to a spring (all spring-related settings are turned off).

Surely lots of people have successfully made a 2D pendulum with Unity physics??

any help is appreciated,

D.

error.png (37.8 kB)
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

4 Replies

· Add your reply
  • Sort: 
avatar image
1

Answer by aldonaletto · Aug 16, 2012 at 01:38 AM

It seems that the connecting body is colliding with the cube and causing this weird behaviour. You can simply remove the cube: set the Connected Rigidbody field in the hinge joint to null, what means "connected to the world" for the physics engine. But if you really need the cube, replace the hinge joint by a fixed joint and enable rotation only in the desired cube axis: the whole pendulum will rotate around this axis.

Comment
Add comment · 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
0

Answer by electricsauce · Aug 16, 2012 at 01:47 AM

I tried the same thing, but with axis 1,0,0 on the capsule and it worked correctly for me. I was able to replicate your results by lower the mass of the capsule to close to 0.

Figured it out, it's because your capsule is connected to the outside of the cube. It has to be perfectly centered for it to work.

Comment
Add comment · 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
0

Answer by flamz · Aug 17, 2012 at 02:10 PM

Thanks for your help. I managed to get it working, somewhat, trying both solutions. However, I still get some instabilities using a very simple fixed-joint setup.

Here's how to reproduce the problem:

  • Create a cube

  • move it to (25,10,45)

  • add a rigid body component

  • turn off gravity and constrain in XYZ for both position and rotation (pin the object)

next:

  • Make a sphere

  • move it fairly far away from the cube (I use 60,0,45)

  • add a rigid body component

  • add a fixed joint and use the cube as a connected body.

run the simulation.

result: as the ball falls, it starts to swing as it should, like a pendulum. But then, when it reaches the apex of the curve, it starts to behave as though it was connected to the cube using a spring and starts to bounce around.

if you move the ball closer to the cube, everything runs fine. Or if you reduce the ball's mass, everything is fine as well, which makes me wonder what the "infinity" setting means in the "break force" property...

:(

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 electricsauce · Aug 17, 2012 at 02:58 PM 0
Share

Yeah, Unity's physics can get weird sometimes. If you're just trying to make the look of the pendulum attached to the cube you could probably parent the cube and the pendulum to an empty and attach your capsule(arm) to the world via a hinge joint like aldo suggested.

avatar image
0

Answer by Pavan Shinde · Aug 31, 2012 at 07:04 PM

Hi, I got the simple pendulum working nicely. This is how I'm doing; create 2 spheres with some distance between them. Freeze rotation and position for a sphere, change its mass to 50 and uncheck the "Use Gravity" check-box. Put a spring joint between the spheres and make Spring value 9e+37.

Comment
Add comment · 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

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

2D 360 degress platformer example needed 0 Answers

If a joint has a Connected Body, does it ignore the Anchor position? 1 Answer

Connecting SpringJoint2D to Rotating Rigidbody2D With Correct Anchor 0 Answers

how to move hinge joint anchor with the object? 1 Answer

Can't set hingeJoint.useLimits at runtime 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