• 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 ThomasQ · Dec 18, 2011 at 03:22 PM · ragdoll

Instantiated Ragdoll bounces back for 1 frame

Hi All!

If been polishing up on my ragdoll skills, but there is one little last problem.. Upon Instantiating the ragdoll, I give it the velocity of the gameobject that spawned it. However there seems to be this little jitter, that influences the rest of the trajectory of the ragdoll. Upon examining slowed down video footage I noticed that jitter is happening the first frame the ragdoll is spawned. It bounces back just a tiny bit, before continuing in the correct direction..

You can see the footage here: http://www.youtube.com/watch?v=LR3zxVNv1yA

This is the relevant code from the script attachted to the original rigidbody:

 function FixedUpdate()
 {
 lastVel = (rigidbody.velocity * -1);
 lastAngVel = (rigidbody.angularVelocity * -1);
 }
 
 function OnCollisionEnter(collision : Collision)
 {
     if(collision.gameObject.tag == "Player")
     {
     ragdoll = Instantiate(ragdoll, transform.position, transform.rotation);
     colliders = ragdoll.GetComponentsInChildren(Collider);
         for (var col : Collider in colliders)
         {
     Physics.IgnoreCollision(col, collider);
         }
        rigidbodies = ragdoll.GetComponentsInChildren(Rigidbody);
 
     for (var child : Rigidbody in rigidbodies)
         {
         child.velocity = lastVel;
             child.angularVelocity = lastAngVel;
         }    
     Destroy(gameObject);
     }
 }

Obviously, there are a number of different reasons that can cause this problem, but after a few hours I haven't been able to determine what is causing this, and why.

I found one strange thing though: If i don't multiply the original rigidbody's velocity with -1, it bounces the ragdoll backwards / off the player, instead of over / through him. For the ragdoll i used the same model, with the same anchor point etc as for the animated model, so it's not the axis's. Although this is odd, I dont see how turning the velocity value into negatives should push the ragdoll back 1 frame, and then not..

Anybody any idea on what's the cause of this, and how to fix it? Can it perhaps be the joints? Any help will be greatly apriciated!

Thanks in advance!! Thomas

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 aldonaletto · Dec 18, 2011 at 11:31 PM

I tried an alternative: I created an auxiliary trigger volume a little bigger than the actual object's collider, and changed the script to do the ragdoll replacement in OnTriggerEnter instead of OnCollisionEnter - this way, the runner guy will first encounter the trigger and be replaced by the ragdoll, which will actually collide with the obstacle. It worked fine for me - except by the fact that there was two trigger events, thus I had to create a boolean variable replaced that eliminated the second event.

var ragdollPrefab: Transform; private var replaced = false; // avoids second trigger

function OnTriggerEnter(col : Collider){ if (!replaced && col.tag == "Player"){ replaced = true; var ragdoll = Instantiate(ragdollPrefab, transform.position, transform.rotation); var rigidbodies = ragdoll.GetComponentsInChildren(Rigidbody); for (var child : Rigidbody in rigidbodies) { child.velocity = rigidbody.velocity; child.angularVelocity = rigidbody.angularVelocity; } Destroy(gameObject); } } Try this code in your project: create a box trigger and place it a little before the obstacle, and attach this script to the runner guy.

Comment
Add comment · Show 1 · 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 ThomasQ · Dec 20, 2011 at 02:02 AM 0
Share

Thanks! Tried your suggestion, wich showed it was still happening, 4 meters away from the Player.. This eventually led me to an issue with the animation: The rigidbody was rotating, but so was the model in the animation. When I took out that rotation, it worked fine. Thanks again!!

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

5 People are following this question.

avatar image avatar image avatar image avatar image avatar image

Related Questions

Ragdoll's flying 0 Answers

how do i go about making a ragdoll in unity? 3 Answers

Character Body Part Dismemberment 1 Answer

Crash Dummy Sim 0 Answers

Trials ragdoll/bail effect 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