Search Unity

  1. The 2022.1 beta is now available for testing. To find out what's new, have a look at our 2022.1 beta blog post.
    Dismiss Notice
  2. Welcome to the Unity Forums! Please take the time to read our Code of Conduct here to familiarize yourself with the rules and how to post constructively.

Changing Collider Offset Due To IK

Discussion in 'Animation' started by DoomPriestK, Sep 19, 2021.

  1. DoomPriestK

    DoomPriestK

    Joined:
    Nov 23, 2019
    Posts:
    126
    Hello!

    I recently set up Inverse Kinematics with Unity's built in Character Controller so my player will stand on slopes properly, however I want to implement a suggestion someone put in the comments:

    "you should dynamically place the collider based on the height difference across both feet - that's what we do effectively as we shift weight ourselves - so when walking across uneven terrain you will see the person lowered, feet at different heights, and then on flat terrain he'll be walking around at full height so the offset of the collider should be floor+foot difference - he'll "sink" that much with his most extended leg reaching the ground and his other leg bent up, then you need to look at which foot is on ground and animate the collider with the adaptive leg gait so you are raised more on the one that is higher up etc."

    Basically i'm looking to counter what happens in the screenshot below by adjusting the collider offset and height parameter so the collider will shift upwards to let the model stand properly while still having the correct height so it reaches the top of his head:



    Heres the current CC inspector settings:


    And heres a link to my IK code, i'm not sure how I would implement this?

    https://pastebin.com/2zdSrTqt
     
    Last edited: Sep 19, 2021
unityunity