Search Unity

How to make animations be affected by physics ? (kinda)

Discussion in 'Animation' started by Hoshiqua, Jul 22, 2016.

  1. Hoshiqua

    Hoshiqua

    Joined:
    Jul 22, 2016
    Posts:
    77
    Hey there !

    I put "kinda" in the thread name because I'm not sure it's really the question I'm asking but I still wanted to somewhat sum up what I'm asking.

    So basically there's this game a lot of youtubers have made videos with already, it's called "Totally Accurate Battle Simulator". In this lil game, you place down men armed with varying weapons and equipments and watch them duck it out against an opponent army.

    What caught my attention is the way animations seems to affect / be affected by physics so much. I don't really know how to explain it, but animations seem to have their own "force" and can sometimes be deformed, changed.. by physics and whatever is in the way, so in melee fights you see animations "clashing" on eachother and it ends up looking like a drunken brawl, which is fun !

    I tryed to create a similar thing by creating a rigged character made up of primitive shapes like cubes and spheres, and then giving all of its bones one or two primitive colliders so that the whole body is collideable and can be affected by physics properly.

    What I ended up with is a wierd reaction whenever something is too big / heavy to push away.. the character would start walking up in the air for example. Basically, the animation itself would never """adapt""" to the collisions so either the collided object would go flying often quite fast, or the character would completely rotate.

    It got even worse when I tryed to have two characters walk into eachother.. they started walking on eachother towards the sky lol.

    So, I know my question isn't really specific but I'd really like to reproduce something similar as what there is in that game. I don't know if it uses the Unity engine so maybe it's not achievable ?

    EDIT : Something I haven't tried is to assign a rigidbody to each individual bones. I'll edit again when I'm done testing it.

    EDIT2 : It seems the character just slowly sinks into the ground. Or gets other funny reactions. I'm guessing it's because rigidbodies are not made to be constrained into eachother..
     
    Last edited: Jul 22, 2016
  2. theANMATOR2b

    theANMATOR2b

    Joined:
    Jul 12, 2014
    Posts:
    7,790
    You are describing an advanced character controller that reacts to physics. This is an advanced topic/task that someone with limited experience is not going to be able to accomplish.
    Suggest looking into some of the documentation and thread posts for all of the advanced character controllers available on the asset store.
    There is a ton of information you can gather from researching those other controllers, and might enable you to start working towards a character controller that works as desired.
    Or - just buy one of them that has the features you desire.
    Puppet Master - https://www.assetstore.unity3d.com/en/#!/content/48977
    is probably the closest controller to what you have described. I've not used it - but it looks like a quality product.
     
  3. eses

    eses

    Joined:
    Feb 26, 2013
    Posts:
    2,637
    @Hoshiqua

    Interesting topic.

    You mean brawling like in game like "Gang Beasts" and such?

    Not very easy solutions to this. Many games use tools/middleware like IKinema, NaturalMotion's Euphoria

    Read about those and you get the general idea how they work.

    For Unity there are similar solutions that might work for you / not sure if they give as many tools / or more tools, I have no idea of practical quality produced by these solutions, since haven't use any of these (yet):

    1. Ootii's tools like Motion Controller and their Bone Controller.

    2. What @theANMATOR2b mentioned, RootMotion's PuppetMaster and Final IK.

    - Probably some others too.
     
    reyalpsirc and theANMATOR2b like this.
  4. Hoshiqua

    Hoshiqua

    Joined:
    Jul 22, 2016
    Posts:
    77
    Thanks for the answers guys ! I'll check those tools out. And yea I realise it's gotta be a difficult task to make it from scratch. My hope was there could be something integrated to unity for animations to be deformeable by physics.

    I'm guessing I could start by somehow cancelling a "part" of the animation if a part of the body collides with something. Is there any way to know which object's collider in an object hierarchy actually registered the collision ? Since all of my bones have colliders I'm guessing that's the way I could recognize which bone has to stop moving.

    EDIT : I'm thinking I could create a script for bones that could get their animation deformed by physics. In this case it could be registering the collision by itself since it would actually be a component of every bones.. but wouldn't that be very resources-hungry ? Also, wouldn't it register collisions with neighboring bones ?
     
    Last edited: Jul 24, 2016
  5. ramonfr

    ramonfr

    Joined:
    May 28, 2011
    Posts:
    23

    Really?! Did you even watch the videos of the game? It's not that hard, it's all about playing with ragdolls and physics, a person with "limited experience" is able to accomplish that. There's no need to be arrogant. The guy was excited and curious, then you came up with this salty answer. You basically said "you can't do it, F*** off and learn stuff, or buy something that's ready".


    TABS was made in 7 days with Unity3D for a game design competition.

    I suggest the creator of the topic to ask it for the creator of game, I've done it today and I'm waiting for an answer, I'll get to you once I receive it.
     
  6. theANMATOR2b

    theANMATOR2b

    Joined:
    Jul 12, 2014
    Posts:
    7,790
    Nobody is being arrogant - I just stated fact. If you are offended - stop being so sensitive.
    I said it was hard for a beginner. Then suggested researching which leads to learning how to proceed, although this has already been solved in several assets - so it's not a bad idea to see how those have been created.

    Attempting to just "play with ragdoll and physics" will get you pointed in the right direction, but won't accomplish your end goal as mentioned above because the initial setup for ragdoll is all or nothing. It isn't able to be set to only one limb out of the box. But your in luck - several other people have done similar things you want to do.
    No need to blind contact someone else when the information is already available -
    Here are some links that will provide some helpful information.
    http://answers.unity3d.com/questions/1038133/ragdoll-only-for-specific-limb.html
    http://answers.unity3d.com/questions/525678/on-ragdoll-joints-can-i-apply-rotation-force.html
    http://answers.unity3d.com/questions/611389/character-contoller-with-ragdoll.html
    http://answers.unity3d.com/questions/37109/characters-limb-movement-restrictions.html
    http://answers.unity3d.com/questions/548037/how-do-i-create-a-ragdoll-with-fewer-than-13-limbs.html
    http://answers.unity3d.com/questions/581279/combining-partial-mecanim-animations-using-avatar.html
    http://answers.unity3d.com/questions/418973/transition-between-regular-animations-and-ragdoll.html
    Not specifically relevant but helpful.
    http://answers.unity3d.com/questions/16578/100-ragdoll-driven-character-how.html

    Also look into Unitys execution order because you will need to understand when animations and physics are executed and in which order.
     
    Robert_1 likes this.
  7. Mecanim-Dev

    Mecanim-Dev

    Joined:
    Nov 26, 2012
    Posts:
    1,675
  8. Burkard

    Burkard

    Joined:
    Feb 22, 2014
    Posts:
    13
    Maybe this is what you're looking for:
     
    johnpccd likes this.