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 MaGuSware™ · Feb 04, 2014 at 12:21 PM · c#animationragdollbones

How do you set the positions of a ragdoll to that of bones in the last frame of played animation?

Hello, I have encountered a problem with my ragdolls in unity. The way I am doing ragdolls is prefabbing them and instantiated them when the main game object is killed.

They instantiate just fine but I am having trouble setting the positions of the bones to that of the animation at time of death.

Here is what I am doing:

 GameObject ragdoll = Instantiate(m_ragdoll, transform.position, transform.rotation) as GameObject;
 Utilities.ConfigureRagdollPosition(transform, ragdoll.transform);



ConfigureRagdollPosition():

 public static void ConfigureRagdollPosition(Transform reference, Transform ragdollPart)
 {
     ragdollPart.localPosition = reference.localPosition;
     ragdollPart.localRotation = reference.localRotation;
 
     for (int i = 0; i < reference.childCount; i++) 
     {
         Transform ref_t = reference.GetChild(i);
         Transform rag_t = reference.GetChild(i);
 
         if(ref_t != null && rag_t != null)
             ConfigureRagdollPosition(ref_t, rag_t);
     }
 }


The ragdoll just starts up in the T pose, because I'm assuming that animations don't work the way I thought they did (i.e. moving the game objects with the bones).

What is the correct way of doing this?

Additional Info: I am currently working with the unity construction worker model and animations for this. Debug.Log shows that it is iterating through the children recursively.

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
1
Best Answer

Answer by GameVortex · Feb 04, 2014 at 12:56 PM

It seems to me that on line 8. and 9. of that script that you are setting the reference and the ragdoll to be the same transform and therefore will be setting the local position and rotation to be the same as it is. On line 9. you probably want to use the ragdollPart instead (assuming it has the same number of bones and the bones are named the same).

Other than that this is a great way of setting the position of bones for a ragdoll and animations do work by moving/translating the bones of gameObjects.

Comment
Add comment · 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 MaGuSware™ · Feb 04, 2014 at 03:17 PM 0
Share

Oh my god! How the fudge did I miss that!! Super derp. It's always the simplest things. Sorry for wasting your time :D

avatar image GameVortex · Feb 05, 2014 at 07:20 AM 1
Share

Hehe, no problem, just glad you got it sorted out. =)

avatar image Nadan · Jun 19, 2015 at 11:18 AM 0
Share

Hi! I'm still having problems with this. Do you mean like this:

Transform ref_t = reference.GetChild(i);

Transform rag_t = ragdollPart.GetChild(i);

This didn't work in my case. :/

avatar image GetColor · Aug 25, 2015 at 04:59 AM 0
Share

Is there anyway you could clarify the solution? I'm with Nadan, I tried that and it didn't seem to work. If you could post the fixed code you'd be my hero!

avatar image GameVortex · Aug 25, 2015 at 06:26 AM 0
Share

@Nadan & @Sussy Your issue might be different from what the Original Question is about. With just the information "It does not work" to go by it is not easy to fix the problem. You should post a new question about your specific issue and reference this question. Remember to provide as much details as possible.

@Sussy: The fixed code is what @Nadan writes.

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

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

Related Questions

Ignore Bones in Animation 1 Answer

Ragdoll only for specific limb 2 Answers

[C#] How would I create skeleton bone transforms from a TRS matrix? 0 Answers

Ragdoll on Only Part of a Model 2 Answers

save my ragdolls current pose in c# 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