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 saldavonschwartz · Oct 16, 2013 at 04:34 AM · physicsrigidbodyjointsspringjoint

basic questions about spring and joints in general

I'm trying to connect two rigid bodies with a spring joint in between them and have some question. Mind you, even though I'm trying specifically with a spring at the moment, some of these questions are really about joints in Unity in general:

  1. Is it possible to model a spring with two ends and one body on each end and have the 2 ends behave the same with respect to each other?

    For instance, in Apple's SpriteKit, which under the hood uses box2d, a spring joint connects one body with another (it has physicsBodyA and physicsBodyB properties and anchorA and anchorB properties). That is, both bodies and anchor points are at the same hierarchical level. In Unity however, I'm confused about the hierarchy and the ConnectedBody vs Anchor implication. It seems as if at some point, a joint is a one-way relationship: the body you add the spring to becomes the "free" end of the spring and the ConnectedBody property, even if referencing another body, does not allow this other body to move in the same way the parent of the joint component moves.

    The best example I can think of is this (assume A and B are rigid bodies with say, box colliders).

    • A has SpringJoint component
      • SpringJoint.ConnectedBody = B

      Rotating A around B will cause B to rotate about its center as if "watching" B, which I'd expect. However, attempting to rotate B around A does not make A to rotate in place but instead to start strafing towards B until it ill end (for an attempt at rotating 90 degs for instance) almost horizontally aligned with B. Maybe this drawing helps: alt text

      I wonder if it might have something to do with Unity's definition of a spring having a "fixed" end? But if so, would I need to coordinate two spring joints (from A to B and B to A) to get the effect of a single spring with two "free" ends?

  2. I've done some initial testing and it doesn't seem like it is. For example, if A has a joint and that joint's ConnectedBody is B, from that point onwards A and B can intersect each other, which kind of sucks... cause I'm trying to create a sort of physics-affected graph: nodes connected by edges (which would behave like springs for instance) and connected nodes should still not intersect each other on colliding.

  3. What determines the distance between the two bodies joined by a joint? First I thought that their distance at the time of creating the joint was what would get set as the joint length if you will (though this might only make sense if I think about the joint itself as an elastic rod or spring?). Then I thought the min/max distances of the spring joint or the linear limits in the configurable joint would set this. But I get strange results. Say I want A to be joined to B by a spring and the distance between A and B (the spring length if you will) be 10 units. How do I establish the 10 unit distance?

  4. Is it possible to change at runtime the length of the joint / distance between two joined bodies? Following on the previous example, say at runtime I want to change the distance between A and B from 10 to 5. How would I go about it?

jointrotate.jpg (73.9 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

1 Reply

· Add your reply
  • Sort: 
avatar image
0
Best Answer

Answer by Owen-Reynolds · Oct 16, 2013 at 04:56 PM

These are just guessing from playing with joints. I assume they may have been imported from Phys-X, so a better explanation is there:

1) Check the connected position. The ConnectedRigidbody always counts as having the spring connected to the center, so pulling gives smooth rotations. The object with the spring has an adjustable position -- sometimes it defaults to one end of the object. Lots of joint oddness is fixed by adjusting the position.

2) Springs need rigidbodies, but not colliders. Never tried this, but the collision layer matrix might allow springs to work, but allow colliders to pass-through (but would need to be clever with the layers.) Or it might say "diff layers, no interaction, no spring."

3,4) Best as I can tell, "spring length" is determined by initial placement and the settings. Unattaching the joint, moving the object, then reattaching does work in some (possibly all) cases.

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

15 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 avatar image avatar image avatar image avatar image

Related Questions

Rigidbody hover, bodies connected with joints should hover together. 0 Answers

Connecting SpringJoint2D to Rotating Rigidbody2D With Correct Anchor 0 Answers

VR Grapple hooks 1 Answer

Violent shaking when using position drive in Configurable Joints 1 Answer

How to use a joint or other methods to create a joint-like effect that allows a rigidbody to rotate around an anchor in all axes? 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