Search Unity

Changing Collider Offset Due To IK

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

  1. DanielRiches

    DanielRiches

    Joined:
    Nov 23, 2019
    Posts:
    166
    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