Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Animation interferes with Rigidbody?

Discussion in 'Animation' started by kinguhdahood5, Mar 23, 2020.

  1. kinguhdahood5

    kinguhdahood5

    Joined:
    Dec 18, 2018
    Posts:
    84
    Hi, and thanks for reading.

    So, I've been working with a particular project for some time, and every once in a while I have the issue of my animations not working properly. I have a system where you can hit a character and that character will ragdoll, but what's happening is that the character is deactivated and the ragdoll instance is enabled. After some time, the character will respawn, reactivate, but when that happens, I can't rotate my character and/or my character gets stuck in an awkward pose. I know it's due to the animator because I've been making override controllers to play different animations, so after implementing an override controller, these problems occurred.

    Things I've tried:
    - created a script that would destroy the animator onDisable and recreate it onEnable to see if I could reset it.
    - tried messing with culling mode, update mode, and root motion, all of which resulted the same.

    Things to note:
    - the animator and rigidbody is on the same object, not sure if that will affect anything.
    - all movement and control is rigidbody based, I do add force in animation events like dashing forward.
    - I'm currently working with UMotion to make my animations, all of which are generic.
    - the model is an fbx model from blender.

    - settings for the animator
    - root motion: off
    - update mode: normal
    - culling mode: cull updates transforms

    I don't know if this belongs in the animation category or the physics category, but I'm fairly certain that the animator is interfering with my physics in some way. I should also note that I'm still learning on the animation side of things so I could've missed something in terms of how to implement it. I have other animator controllers that work the way they're supposed to, It's just a couple that just don't like to work. It's happening after the character is disabled and then re-enabled, in which I'll have motion issues or my animations get stuck in a pose. Any help would be much appreciated, thank you.
     
  2. Kybernetik

    Kybernetik

    Joined:
    Jan 3, 2013
    Posts:
    2,555
    I prefer to have the model with the Animator as a child of the Rigidbody so that you can always swap out the model without affecting anything else, but I don't think that would be the cause of your issue.

    It has been a while since I looked into it so I can't remember the specifics, but I know that Animator Controllers have a bunch of issues with being reactivated which do not occur in Animancer instead (link in my signature).
     
  3. kinguhdahood5

    kinguhdahood5

    Joined:
    Dec 18, 2018
    Posts:
    84
    Thanks for the response! I ended up temporarily fixing the issue, but I have been having issues with the Animator Controllers. I do like the idea of Animancer, I originally came from gamemaker, where you didn't have a controller, you just assigned an animation, It would be a lot easier for me to work with that type of style. Thanks for letting me know about it, I'll be looking into that, for sure!
     
  4. maizinblu

    maizinblu

    Joined:
    Dec 10, 2020
    Posts:
    2
    HOW do you add an object that has a rigidbody, and the script references that body, to a parent object that has a rigidbody?
     
  5. kinguhdahood5

    kinguhdahood5

    Joined:
    Dec 18, 2018
    Posts:
    84
    Hi maizinblu, I happen to be online at the moment, I'll see if I can help.

    Your question is kind of hard to understand. Are you trying to access a rigidbody from another object's script? Or are you trying to, in a sense, copy a rigidbody to another?
     
  6. maizinblu

    maizinblu

    Joined:
    Dec 10, 2020
    Posts:
    2
    Specifically, when I add an animation or edit an existing animation in the controller, my movement script stops working. I’ve read that creating an empty object with a rigidbody component then placing my object with script and animations into that empy object as child. My question is this: where does the script reside and how does it effect the child?
     
  7. kinguhdahood5

    kinguhdahood5

    Joined:
    Dec 18, 2018
    Posts:
    84
    Well, in the projects I've created, I mainly have everything in one object, so the Animator, Rigidbody, and Movement script that I have setup are inside the same object. Regarding creating a child object of a Rigidbody and storing your Animator and Movement script there, I've read that too, but I haven't necessarily experienced a difference in either situation. Troubleshooting animator issues tends to be problematic, but, in my experience, it usually comes down to how the script works.

    To your other question, your script shouldn't effect your child unless you specifically ask it to. If you effect the Rigidbody, the Rigidbody itself effects all the children within that object, that's something to note. I can't really help a great deal because there's not a lot of information to work on here. Have you made a post about it in the scripting forum? You'll likely get some better answers there, but I would give some more detail on the matter, like showing what you have in your movement script.
     
  8. CoderCole

    CoderCole

    Joined:
    Feb 27, 2022
    Posts:
    1
    I know this thread is pretty old, but I was having the same issue and the fix was extremely simple and I didn't see it posted already. Just disable the "Apply Root Motion" option in the animator, and the physics should work as intended. Hope this helps
     
    Deleted User likes this.
  9. Deleted User

    Deleted User

    Guest

    Thanks. In my case my character's gravity was not working as it should be. Just disabled the Apply root motion and now it is working fine.