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 sheffieldlad · Dec 31, 2013 at 02:10 AM · modelragdoll

turn player model into rag doll

Hi all,

I am making a 2.5d infinite runner game using a 3d model as the player. The 3d model is animated to run. I would like to turn the player model into a rag doll when the game is over. Here are a few code snippets before I elaborate on my problem...

The following code checks for user input, checks to see if the player is touching a platform then jumps if both of these conditions are met.

the second part checks to see if the player is touching the platform and if this condition is met applies acceleration.

 if(Input.touchCount > 0 && Input.GetTouch(0).phase == TouchPhase.Began){ //Android touch controls.
             if(touchingPlatform){
                 numberOfJumps +=1f;
                 GUIManager.SetnumberOfJumps(numberOfJumps);
                 rigidbody.AddForce(jumpVelocity, ForceMode.VelocityChange);
                 audio.Play();
                 touchingPlatform = false;
             }
             
         }
         if(transform.localPosition.y < gameOverY){
             GameEventManager.TriggerGameOver();
         }
 
         speed = rigidbody.velocity.x;
         //add some speed
         
             if(touchingPlatform){
                 rigidbody.AddForce(acceleration, 0f, 0f, ForceMode.Acceleration);
 }



here is part of my game over function which is relevant to my problem.

 Public void GameOver () {
         
         Renderer[] rs = GetComponentsInChildren<Renderer>();
         foreach (Renderer r in rs)
         r.enabled = false;
         rigidbody.isKinematic = true;
 }

The above code grabs each child of the model and turns off the renderer. it also makes the rigid body kinematic. As stated above, I need to turn him into a rag doll at game over.

My first idea was to have the player model as a rag doll to begin with and turn off his animation during the game over event. When I tried this the player model jumps and twitches while the game is running and doesn't accelerate.

Is this due to the way I am applying force to the rigid body? As I see it, a rag doll is a bunch of rigid bodies all together. Would I need to apply acceleration to each one or am I barking up the wrong tree?

Would a better (but more complicated) idea be store my players rotation, speed and position then hide it and instantiate a rag doll?

I've been trying to solve this for a while and I would appreciate any help.

Many thanks,

Paul.

Comment
Add comment · Show 3
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 HERMES123 · Dec 31, 2013 at 04:11 AM 0
Share

I'd say go ahead and try and create a ragdoll and instantiate it in the position and rotation of the player. Here is what I have used. Anim Object being the player I had before and DeadReplacement the Ragdoll. You just have to create the ragdoll.

if (Health <= 0.0) { Destroy(gameObject); Instantiate( DeadReplacement, AnimObject.transform.position, AnimObject.transform.rotation);

     }
avatar image Vonni · Dec 31, 2013 at 06:02 AM 0
Share

You could set up your character with all the joints and rigidbodies beforehand. Once the game ends, iterate through all the rigidbodies and enable them

avatar image sheffieldlad · Dec 31, 2013 at 09:00 AM 0
Share

$$anonymous$$any thanks both of you. I won't have time to try either of these till the new year but I'll come back and let you know how it went.

0 Replies

· Add your reply
  • Sort: 

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

Where could I get a Free 3d Ragdoll Model? 1 Answer

Ragdoll script vs Extra ragdoll model 0 Answers

Unity Robot - left forearm glitchy transform 0 Answers

Blender or Unity for animation? 4 Answers

Ragdoll effect on models 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