Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We are updating our Terms of Service for all Unity subscription plans, effective October 13, 2022, to create a more streamlined, user-friendly set of terms. Please review them here: unity.com/legal/terms-of-service.
    Dismiss Notice
  3. Have a look at our Games Focus blog post series which will show what Unity is doing for all game developers – now, next year, and in the future.
    Dismiss Notice

Changing Collider Offset Due To IK

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

  1. DoomPriestK

    DoomPriestK

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