Search Unity

Question Stretch and contract animated character depending on distance to ground

Discussion in 'Animation' started by schwmm, Sep 11, 2022.

  1. schwmm

    schwmm

    Joined:
    Oct 20, 2020
    Posts:
    62
    Hi!
    Please refer to the image I attached.
    Imagine my character to be a bouncy banana that can jump. It has an armature with a jumping animation which I would like to play depending on it's distance to the ground.
    Basically, when the Banana is fully on the ground, it is completely contracted / bent. If it is fully in the air, it is stretched open. Once it comes close to the ground, it starts to contract again, until the capsule character collider (red sphere) touches the ground again, where it can then jump again.

    I imagine something like this to be done with an IK point at the bottom "tail" end of the banana? The difficulty for me is, that this point should have a fixed range how far it can move from the center of the character. It should only move vertically and it should have a rigidbody to collide with the environment and in the best case "snap" on top of an obstacle if the tail hits the obstacle sideways.

    In addition, it should then somehow control the full animation - I want the full banana to stretch when off the ground, not just the tail. So also the top half should stretch if the IK point moved away from the center of the character.

    How would I best achieve that? With an IK system on top of my other animations? Or maybe a script that measures the distance of the "IK point" from the center and controls the animation accordingly?