• 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
Question by thaiscorpion · Oct 24, 2013 at 08:46 AM · javascriptphysicshierarchyjointhingejoint

How to use Hinge Joints correctly inside a parent?

I'm trying to create a cube with two 'legs' using hinge joints so they move like spaghetti using the physics engine :D

The issue I'm having is that when I have created a 'leg' and I want to join it on to my cube that works oky but when the cube and the 'leg' are inside a parent and I move the parent the movement doesn't affect the physics anymore.

Img of hinges

My parent hierarchy is like this:


Character


  1. Head (Another mesh)

  2. Body (Another mesh)

  3. Cube
    1. Leg1
      1. Anchor

      2. Joint1

      3. Joint2

      4. Joint3

      5. Joint4

    2. Leg2
      1. Anchor

      2. Joint1

      3. Joint2

      4. Joint3

      5. Joint4


Now I want to have Character as a prefab, and when character moves the physics of that movement affect the joins but it doesn't.

Any idea how to fix this issue? thanks!

Comment

People who like this

0 Show 0
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
Best Answer

Answer by Owen-Reynolds · Oct 24, 2013 at 03:56 PM

Don't use parenting.

Moving the parent also moves the child legs. It moves them first, "by magic." Then the physics step sees the leg is perfectly under the body, so has no reason to do anything.

Comment
thaiscorpion
Westland

People who like this

2 Show 5 · 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 thaiscorpion · Oct 24, 2013 at 05:29 PM 0
Share

But without parenting I can't make a prefab out of it can I?

avatar image sdgd · Oct 24, 2013 at 05:34 PM 1
Share

I'd parent everything and on Start() detach children something among those lines

avatar image ThatOwlGuy · Oct 24, 2013 at 08:30 PM 2
Share

You could try making an object and then parent everything separately under the object so that instead of the cube being the parent that dictate the position, it will be a "sibling" under the prefab. That way you don't have to write any scrip.

avatar image thaiscorpion · Oct 24, 2013 at 09:58 PM 0
Share

@Sakka9826 thanks for your comment, the issue with this is if I move that object then the physics engine won't affect the joints I think. @sdgd Thanks! I might have to do that then :D was just hoping there would be a natural way to do it in unity, guess not hehe

avatar image Owen-Reynolds · Oct 25, 2013 at 12:07 AM 1
Share

As per Sakka's comment (all children of fake empty parent) it would be easy code, just after the Instantiate:

foreach(Transform tran in thingIJustMade) tran.parent=null; then Destroy( thingIJustMade );

If you need a pointer to the "parent" cube (now not really a parent,) start out with Transform cube = thingIJustMade.Find("cube"));

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.

Welcome to Unity Answers

If you’re new to Unity Answers, please check our User Guide to help you navigate through our website and refer to our FAQ for more information.

Before posting, make sure to check out our Knowledge Base for commonly asked Unity questions.

Check our Moderator Guidelines if you’re a new moderator and want to work together in an effort to improve Unity Answers and support our users.

Follow this Question

Answers Answers and Comments

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

Related Questions

Hinge joints not reaching target position 1 Answer

Pushing a cart with a vehicle (Not generating initial torque) 0 Answers

Disable weight "inheritance" when using HingeJoint2D? 1 Answer

Why are my hinge joints inaccurate? 1 Answer

Can't change HingeJoint properties by script 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