Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

Hit Reaction - Ragdoll System

Discussion in 'Assets and Asset Store' started by username_unity_of_my, Oct 27, 2015.

  1. username_unity_of_my

    username_unity_of_my

    Joined:
    Feb 24, 2015
    Posts:
    330
    Hello

    I released new package on asset store.
    Its accurate physics hit reaction and ragdoll system for unity mecanim.
    Simulates hit reaction on hit body parts and blends with ragdoll and animator. Get up animations included.
    Included are third person shooter game that implements above systems and example usage of ragdoll manager on standard assets AIThirdPersonCharacter.

    Important:
    Import into new project.
    If you need only Ragdoll system copy 'Ragdoll System' folder and 'Editor' folder to your project.
    There are lots of example scenes and they require tags, layers etc. which you probably dont need in your project.


    Link to asset store page: HERE

    Included in package:
    - third person shooter game
    - third person controller script
    - player and npc control scripts
    - camera controller script that follows,rotates and zoom to player
    - light beams shaders
    - finished player and npc prefabs
    - ragdoll manager on standard assets AIThirdPersonCharacter example with prefab and scene
    Also examples of usage: adding forces to ragdoll, adding force to individual body part, interaction with joints etc...

    Here's demo video:


    And here is setup tutorial and demo:


    [Edit]
    This is generic setup video:



    For more insight you can check web players:
    Player 1
    Player 2

    Thank you
     
    Last edited: Feb 12, 2018
    Gozdek, kurotatsu and theANMATOR2b like this.
  2. dibdab

    dibdab

    Joined:
    Jul 5, 2011
    Posts:
    976
    this is good. there was a time when there was no ragdoll physics - animation blending for unity and looks like there will be at least 4 of them soon.

    this looks like a decent start (it's easy to set-up for sure) and would like to see it being developed further into a robust system.

    1. will the character fall when hitting an obstacle (or stumbling on uneven surface)? does these forces add up, the character's own motion against static objects?
    2. did you try if animation's force alone strong enough to knock out a character (when 2 characters fighting)?
    3. does it work with generic?
    +1. would it be possible somehow to apply a pose on ragdolled character?
     
  3. username_unity_of_my

    username_unity_of_my

    Joined:
    Feb 24, 2015
    Posts:
    330
    This is the system that I use in my project/s.I oriented more on performance ( when not in ragdoll - I disable detect collisions and manually checking for collisions, but that is optional - you can choose to not disable it and use regular physics). There is no parallel transform tree and animator gets disabled when ragdoll starts.

    But thank you very much for suggestions.

    1. hmmm, should the player fall when hitting the wall ? Or if its low obstacle maybe he will trip over or just stop or step on the obstacle. There are many things that people will think of.
    I will implement tripping/falling over obstacle based on speed of character on the next updates.

    2. well, I concentrated on third person shooter in the package demo, but same principle applies in fist fight - checking for collision and applying force ( you can get from rigidbody velocity or checking previous position with current or else ).
    I happen to have boxing animations so I will also make demo of fist fight in the next updates.

    3. Currently It only works with humanoid. But I will make it work with generic in the next update. I having a hard time thinking how to make building of ragdoll setup simple ( lets think of spider will 6 legs or giraffe with 4 legs and long neck or some kind of centaur with 4 legs and 4 arms and 2 heads). But for actual ragdoll system its 10 mins of work - just a little modification.

    What do you mean with applying the pose. When not in ragdoll rigidbodys are kinematic, they will follow animator transform positions/rotations.

    Thank you.
     
  4. Gozdek

    Gozdek

    Joined:
    Jun 21, 2015
    Posts:
    356
    Great!
     
  5. username_unity_of_my

    username_unity_of_my

    Joined:
    Feb 24, 2015
    Posts:
    330
    Thank you!
     
  6. username_unity_of_my

    username_unity_of_my

    Joined:
    Feb 24, 2015
    Posts:
    330
    BTW
    Regarding fist fights.
    You can derive from ProjectileBall script which detects collisions with body parts based on previous and current positions.Put it as a child of character fist / hand bone transforms.
    Just remove parts of script that control movement of ball and let parent control its movement.
    It will detect collisions with other character body parts so you can use it in fist fight.
    I plan to make fist fight demo in next updates.
     
  7. MorbiusTepes

    MorbiusTepes

    Joined:
    Nov 5, 2015
    Posts:
    4
    Great asset. Does exactly what it says. Especially pleased with low performance cost
     
  8. username_unity_of_my

    username_unity_of_my

    Joined:
    Feb 24, 2015
    Posts:
    330
    Thanks
     
  9. username_unity_of_my

    username_unity_of_my

    Joined:
    Feb 24, 2015
    Posts:
    330
    I released an update to package with bugfixes, improvements and changes to new versions of Unity.
    Package was made originally with Unity 5.1, now its updated for 5.2.2 and 5.2.3.

    Also note that I made system work with generic avatars. It will be released in next update.
     
    Last edited: Dec 1, 2015
  10. username_unity_of_my

    username_unity_of_my

    Joined:
    Feb 24, 2015
    Posts:
    330
    New update is released. It supports generic avatars now. Plus lots of other improvements.

    Here is generic setup tutorial. Its rather long because I was doing all from scratch.
    You can skip to near the end of video to see the results ( 27:00 )
     
  11. dibdab

    dibdab

    Joined:
    Jul 5, 2011
    Posts:
    976
    aaah I dont have enough on my account, will have to wait if next month will have enough unless you take 20dollars now and later the rest :) had to try

    anyway, it looks great.
    it will detect collisions by coll.name and/or it will work as physics (so force could be applied by coll.name)?
    and is there an 'event' / boolean that keeps track of when goes back to animator (follow animator), so new animation can be turn on (by animator.setbool?), so that would switch anim, damage etc (?)
     
  12. username_unity_of_my

    username_unity_of_my

    Joined:
    Feb 24, 2015
    Posts:
    330
    You can use ray/sphere/capsule casting or regular physics - you get index number of hit body part, there are lots of examples in the package.
    It do not detect anything when not in ragdoll - unless you want it to. Its all explained it the docs.
    There are lots of events - when hit, when transition start, when transition ends, when get up end, last event ... they are all implemented in example scenes.
     
    Last edited: Jan 20, 2016
  13. plysaght47

    plysaght47

    Joined:
    Jul 2, 2015
    Posts:
    21
    Where can I find the fist fight scene you were talking about?
     
  14. username_unity_of_my

    username_unity_of_my

    Joined:
    Feb 24, 2015
    Posts:
    330
    Its not finished yet.
    I will post here when its done.
     
  15. theLittleSettler

    theLittleSettler

    Joined:
    Jul 14, 2012
    Posts:
    36
    Interested in this in a wolf fight (player can dodge around and strike wolves with short sword), for the wolves' reactions. No time for it now, but when/if I get the chance I'll give it a go. A fist fight demo would be awesome to see.
     
  16. syabro

    syabro

    Joined:
    Oct 8, 2014
    Posts:
    1
    Hello. I use Hit Reaction. I have an issue: on start blendToMecanim skeleton blinks before the GetUp animation. How can I fix it?

    Video with the bug: https://monosnap.com/file/Z6NmTLaMcpL3E1P53weNXMIZ1Vt1AX
    RagdollManager properties: https://monosnap.com/file/OwkaRAOp8vqJdrExOXtGUeuoTmFnqR.png

    Code (CSharp):
    1.  
    2. if (Input.GetKeyDown(KeyCode.I))
    3. {
    4.     RagdollManager.startRagdoll();
    5. }
    6.  
    7. if (Input.GetKeyDown(KeyCode.O))
    8. {
    9.     RagdollManager.blendToMecanim();
    10. }
    11.  
    Code (CSharp):
    1.  
    2. RagdollManager.startRagdoll(bodyParts, -transform.forward*damage)
    3.  
     
    Last edited: Dec 23, 2016
  17. username_unity_of_my

    username_unity_of_my

    Joined:
    Feb 24, 2015
    Posts:
    330

    Hello, contact me on email - i will send you fix.
    And I will update package with fix very soon..
     
  18. Jasper1hu

    Jasper1hu

    Joined:
    Mar 21, 2015
    Posts:
    11
    Hi,

    I am currently working on a soul-like game. I want to great large boss monster with per bone collider, so that the player can walk under tall large monsters and will only collide with monster's lag like in dark souls or monster hunter. I'm wondering if this asset can accomplish what I am trying to do. Please let me know. Thank you so much!
     
  19. username_unity_of_my

    username_unity_of_my

    Joined:
    Feb 24, 2015
    Posts:
    330
    Sure it can. That is the point of this asset - per bone hit colliders/reactions.
     
  20. vinaykk

    vinaykk

    Joined:
    Mar 22, 2015
    Posts:
    3
    Hi, I loved your work on ragdoll. I wanted to ask you just one thing that can i detect collision on ragdoll parts without the ray casting ?
    Anybody Can Help !!
     
  21. username_unity_of_my

    username_unity_of_my

    Joined:
    Feb 24, 2015
    Posts:
    330
    I dont have that implemented in package, but you can. Just move collision code from raycast to OnCollisionEnter/Stay or OnTriggerEnter/Stay methods. Check for BodyColliderScript and call ragdoll on BodyColliderScript.ParentRagdollManager.startRagdoll.
     
  22. vinaykk

    vinaykk

    Joined:
    Mar 22, 2015
    Posts:
    3
    Thank you, I will try it right now !!!
     
  23. username_unity_of_my

    username_unity_of_my

    Joined:
    Feb 24, 2015
    Posts:
    330
    Hello,
    So, I released version 2.3 of package in which I included examples of explosion and collision with regular physics rigidbody and ragdoll.
     
  24. eyo

    eyo

    Joined:
    Jul 12, 2012
    Posts:
    35
    Hi, just a quick question about your asset. Is it possible to derive hit information from the collider meshes, so for example shooting the leg reduces enemy health differently than say shooting the head, arms or torso?
     
  25. username_unity_of_my

    username_unity_of_my

    Joined:
    Feb 24, 2015
    Posts:
    330
    Sure, on each of body collider there is BodyColliderScript component - there is enum with body part types ( Head, LeftLeg etc.. ) . So you can use it to add damage based in body type.
     
  26. Lemma

    Lemma

    Joined:
    Apr 3, 2013
    Posts:
    4
    Hello, I am trying to make a hit reaction system based on physics. I saw there was a T-pose solider and a solider with fully active rigid bodies in the video. But I need hit reactions while doing something such as getting hit while running and jumping. I'm just wondering if your plug-in supports that as well?

    And one more question: Is all your source code included in the package?
     
  27. username_unity_of_my

    username_unity_of_my

    Joined:
    Feb 24, 2015
    Posts:
    330
    Oh, what would be the point if character has to be in T-Pose always? It would be useless :) Of course you can have animated character receive ragdoll and hit reactions.
    Its full source code included.
     
    Last edited: May 8, 2017
  28. ViveLeCommune

    ViveLeCommune

    Joined:
    May 2, 2015
    Posts:
    27
    First of all, love this asset, its exactly what I was looking for. I have what may be a dumb question tho: how do I get the character to stay ragdolled permanently?
     
  29. username_unity_of_my

    username_unity_of_my

    Joined:
    Feb 24, 2015
    Posts:
    330
    These are the lines responsible for getting up character after ragdoll:
    m_Player.ragdoll.ragdollEventTime = 3.0f;
    m_Player.ragdoll.OnTimeEnd = () =>
    {
    m_Player.ragdoll.blendToMecanim();
    };
    So, after 3.0 character get up and return to animated state. To stay ragdolled just delete/comment these lines - or set character to begin deactivate or destroy procedure.
     
    ViveLeCommune likes this.
  30. fieldrequired

    fieldrequired

    Joined:
    Feb 26, 2014
    Posts:
    108
    Hey there, firstly I have to say this asset is AMAZING - thanks so much for developing it.

    Secondly, in 5.6.1 they added a third spine bone - i'm about to pull the trigger on the upgrade but thought i'd check first, does this change anything with the plugin? Everything working OK?

    Assuming so as there are recent posts here and no mention of it... thanks again!
     
  31. username_unity_of_my

    username_unity_of_my

    Joined:
    Feb 24, 2015
    Posts:
    330
    Thank you!
    I downloaded and tested on 5.6.1 and it works fine.
     
    fieldrequired likes this.
  32. lod3

    lod3

    Joined:
    Mar 21, 2012
    Posts:
    661
    @username_unity_of_my Have you by chance given any thought to UFPS integration, or is this strictly for programmers? I got this working in an isolated environment, using only the mechanics supplied in this asset, and it blew my mind! But, yeah, my attempt at using it with UFPS was a disaster. I wear a great many hats, but coding/scripting is the only hat that doesn't fit ;)
     
  33. username_unity_of_my

    username_unity_of_my

    Joined:
    Feb 24, 2015
    Posts:
    330
    I haven't tried it with UFPS but I dont think it should be a problem. Just check what happens in UFPS LateUpdate methods and order scripts. Also deactivate any UFPS components which may interfere in RagdollManager.OnHit callback like in examples in package. You can activate them again on RagdollManager.LastEvent when character gets up again.
     
  34. dhuang

    dhuang

    Joined:
    Jan 5, 2016
    Posts:
    40
    Hi, is it possible to use hit reaction on a generic model like spider? would it be done differently from a humanoid?
     
  35. dhuang

    dhuang

    Joined:
    Jan 5, 2016
    Posts:
    40
    also, is there any compatibility issue with unity 2017.0? I am getting some errors right away, saying a bunch of missing namespaces.
     
  36. username_unity_of_my

    username_unity_of_my

    Joined:
    Feb 24, 2015
    Posts:
    330
    You can use it on generic models. Here's tutorial video:


    Also, I'll look into the 2017 issue...
     
  37. username_unity_of_my

    username_unity_of_my

    Joined:
    Feb 24, 2015
    Posts:
    330
    I just tried with 2017.1 and it works fine. There are some import warnings , its from older version of unity but project works fine.
     
  38. dhuang

    dhuang

    Joined:
    Jan 5, 2016
    Posts:
    40
    I am getting these errors after importing the entire asset into my existing project.
    upload_2017-9-11_21-35-24.png
    I can see ragdollManager and IragdollUser scripts are all imported, but for some reason it just doesn't recognize the MLSpace namespace, although i see it defined as a namespace in the ragdoll manager.
     
  39. username_unity_of_my

    username_unity_of_my

    Joined:
    Feb 24, 2015
    Posts:
    330
    try adding line:
    using MLSpace
    to the top of the AICharacterCustom script.
    or add MLSpace. in front of every RagdollManager script where it says its error.

    If using MLSpace is already added, then try to reload solution or try to create new project.
    I cannot recreate error - it always recognize MLSpace namespace on me.
     
    Last edited: Sep 11, 2017
  40. dhuang

    dhuang

    Joined:
    Jan 5, 2016
    Posts:
    40
    Hi, I deleted the AIthirdpersoncontroller and it worked. I am trying to get the hit reaction to work on the spider, but every time the spider gets hit, part of the body is detached as the rest of the body launches forward. The hit reaction only looks natural when hitting an idle animation when the spider is stationary. if I hit the spider while it's walking or attacking, the belly of the spider detaches and the rest of the body shakes in an unnatural way. see the attached video. Am I doing something wrong?

    https://drive.google.com/file/d/0B2AQDFCvVYI8NW9WSW95WkNmZGM/view?usp=sharing
     
  41. username_unity_of_my

    username_unity_of_my

    Joined:
    Feb 24, 2015
    Posts:
    330
    Hmm, did you setup the constrains right. For generic rigs colliders, bodies and joints need to be setup manualy.
     
  42. dhuang

    dhuang

    Joined:
    Jan 5, 2016
    Posts:
    40
    I did setup the ragdoll manually, adding capsules colliders , rigidbody and the character joints. For character joints I just used the default settings, did not change anything in there. Should I be changing anything in character joints to set the constraints? I tried to play around with the swing limit but it didn't help at all.
     

    Attached Files:

  43. username_unity_of_my

    username_unity_of_my

    Joined:
    Feb 24, 2015
    Posts:
    330
    Do you disable all input, movement and all conflicting scripts/methods in OnHit callback and enable them again in LastEvent ?
    Try that, I see your spider moves while being hit.
     
  44. dhuang

    dhuang

    Joined:
    Jan 5, 2016
    Posts:
    40
    Hi, I stopped the navmesh agent onHit, it helps a bit, but it looks like there is something weird about the animation itself, the detachment of the body still happens.

    If I just play the animator, without any movement input or navmesh, whenever I play the attack animation, and hit the spider during the animation, the rest of the body launches forward to attack, but the belly stays behind and detached from the rest of the body. the see attached video. I played the attack animation twice, which everything looks fine. The last two times I pressed spacebar to activate the raycast to hit the spider, and the belly detaches from the spider. It didn't have any input or movement scripts on it.
    https://drive.google.com/file/d/0B2AQDFCvVYI8WTNXSW12eVY3bFE/view?usp=sharing

    upload_2017-9-13_9-31-22.png
     
  45. dhuang

    dhuang

    Joined:
    Jan 5, 2016
    Posts:
    40
  46. Novacane89

    Novacane89

    Joined:
    May 3, 2013
    Posts:
    15
    Hi There,

    I have purchased your Ragdol Manager Asset recently and i like the way you implemented the code behaviour between ragdoll and Animator however i am having quite some difficulty implementing this system into the Realistic FPS Package, I have tried importing both on a empty project, importing your solution first and then importing the Realistic FPS prefab package which alters the Project settings just like yours, I have gotten rid of the input parameter errors and re-adding the tags/layers you are using along with the FPS packages tags/layers. some are the same and after i have done that i dont get any errors anymore but the functionality is broken and the example scenes run without error but dont work.

    My fps Realistic Prefab project file is massive with loads if assets imported but not conflicting as i cleaned them up and made sure after every import, I have made alot of enhancements on the FPS realistic prefab AI and added Tactical shooter AI, I would love it if you could give me some documentation for step by step integration for Realitic FPS Prefab. I am willing to pay for that even.

    Best Regards
    Novacane89 -Graham Harris
     
  47. username_unity_of_my

    username_unity_of_my

    Joined:
    Feb 24, 2015
    Posts:
    330
    Its hard for me to figure it out like this over forum. Is it possible for you to send me model of spider so I can try.
    You see, its important to setup ragdoll properly. With as less colliders/rbodies/joints as possible, also that colliders dont overlap, also without large difference of mass value. How many colliders are you using?
     
  48. username_unity_of_my

    username_unity_of_my

    Joined:
    Feb 24, 2015
    Posts:
    330
    Can you please send me mail so we continue this over mail?
     
  49. happydayss

    happydayss

    Joined:
    Jun 13, 2017
    Posts:
    8
    Hello, recently i've been having problem with your asset. When ever I press create after assigning the bones Unity crashes. It's really annoying and fringing on my game progress. Model is Humanoid and using Humanoid script. please help.
     
  50. username_unity_of_my

    username_unity_of_my

    Joined:
    Feb 24, 2015
    Posts:
    330
    Can you please send me mail to sort this ...