Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 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 tsondhi2006 · Aug 16, 2017 at 12:22 PM · ragdolldeath

Ragdoll Death Script

can any1 plz tell me how to make a ragdoll death script ie If a player dies then i want the player to be destroyed and ragdoll to come, taking the position of the player......right now the instantiated ragdoll is taking the position and rotation of the player but not the positions and rotation of the bones.. this is my script for bones positioning which is not working....

public class Ragdoll : MonoBehaviour {

 private List<Transform> poseBones = new List<Transform>();
 private List<Transform> ragdollBones = new List<Transform>();

 public void CopyPose(Transform pose)
 {
     AddChildren(pose, poseBones);
     AddChildren(transform, ragdollBones);

     foreach (Transform b in poseBones)
     {
         
         foreach (Transform r in ragdollBones)
         {
         
             if (r.name == b.name)
             {
                 r.eulerAngles = b.eulerAngles;
         
                 break;
             }
         }
     }
 }

 public void AddChildren(Transform parent, List<Transform> list)
 {
     list.Add(parent);
     foreach (Transform t in parent)
     {                    
         AddChildren(t, list);
     }
 }

}

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

Answer by Eggtooth · Aug 16, 2017 at 12:26 PM

Actually I have created that very thing lately. You do NOT need to replace anything with ragdoll. I've used one model that ragdolled upon death.

The Gist of it is basically being able to smoothly transform from mecanim to ragoll. Download Ragdoll Helper for that.

http://perttuh.blogspot.fi/2013/10/unity-mecanim-and-ragdolls.html

First, make sure that all ragdoll colliders are set to kinematic. Ragdoll Helper does that for you automatically, in my project I use PuppetMaster for Ragdoll and I think Ragdoll Helper finds by itself Rigidbodies and sets them to kinematic, and basically upon death all you need to do is call boolean

 ragdoll.ragdolled = true


...to successfully ragdoll character and set all rigidbodies to Non-Kinematic. YOU MUST REMEMBER: Have character as humanoid and have bones correctly attached.

Next, after this, you will need to make separate layers for ragdoll colliders and collider for the character controller itself. Basically make so ragdoll collider doesn't collide with the collider that is used for third/first person (preventing physics from freaking out) in physics settings. Then, upon death, make sure all ragdoll Rigidbodies are NOT set to Kinematic (which will be taken care by Ragdoll Helper itself), turn on Kinematic for player controller and turn off character controller collider as well.

Excuse me if explanation is convoluted, but I've explained best I could.

Keep in mind that the solution I have shown is good only for third person/2,5D/TopDown games/FPS with full body awareness.

Comment
Add comment · Show 2 · 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 tsondhi2006 · Aug 16, 2017 at 12:33 PM 0
Share

this script is attached to the ragdoll and player death script is calling copypose function

avatar image Eggtooth tsondhi2006 · Aug 16, 2017 at 12:47 PM 0
Share

Well, I have made it that way and it works just fine here. However here I have full body awareness for both first person camera and third person one.

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

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

Related Questions

How to implement Mob movement / death ? 1 Answer

How to make is kinematic false for all children of a gameobject? 1 Answer

Animated pose, to ragdoll, to dead pose seamlessly 1 Answer

How to effect all objects in an array 2 Answers

How do I make enemies ragdoll after being shot with a Raycast in VR? 0 Answers


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