Search Unity

How to combine ragdoll physics and skeletal animation in 2D?

Discussion in '2D' started by ogblavatsky, Oct 24, 2021.

  1. ogblavatsky

    ogblavatsky

    Joined:
    Oct 24, 2021
    Posts:
    2
    So basically, is there a clean way to both use the 2D skinning/skeleton system along with ragdoll elements?
    I have a decent understanding of both but I'm no expert. When I've attempted this in the past the elements either separate upon movement or go crazy like flying off the screen :)

    Here are some things I'd like to achieve.

    1. Enemy that uses skeletal animation but upon death uses ragdoll physics for randomized/physics based death (collapse)

    2. Player that has either a cape / ponytail / actual tail that trails behind them, but is physics based vs. animation frames.

    3. Ragdoll weapons attached to a 2D skeletal player: whips, mourning stars, prickly vine

    4. Controlling a player / enemy that is 'mostly ragdoll' (lets say 80% of child parts) but maybe the arms or legs are linked to a 'rigid' animation cycle / system.


    Thanks!
     
  2. MarekUnity

    MarekUnity

    Unity Technologies

    Joined:
    Jan 6, 2017
    Posts:
    207
    Hi @ogblavatsky,

    Joints and rag dolls don't like extreme forces applied to them and might become unstable if you directly modify joint position or apply huge amount of force to them.

    @MelvMay created this neat GitHub repo with 2D physics examples that might be helpful to get you started
    https://github.com/Unity-Technologies/PhysicsExamples2D

    Take a look at the FixedJoint2D_RagDoll scene:
    Ragdools.gif
    It contains several rag dolls that resemble 2D characters and each uses Fixed Joint 2D component to bind different body parts together. It also demonstrates how the 'frequency' parameter affects rag doll's behaviour.

    The main character in the Lost Crypt demo - Sara - she has a ponytail that's being controlled by physics. You also might take a look at that project and see how it was attached to the character and how it behaves as she moves.
     
  3. ogblavatsky

    ogblavatsky

    Joined:
    Oct 24, 2021
    Posts:
    2
    Thanks Marek, i'll check both those out - I've been meaning to look at that Lost Crypt demo, I bet I could learn a bunch from it.
     
    MarekUnity likes this.