Search Unity

Resolved How to implement Match target Jump (best practice?!)

Discussion in 'Animation' started by canis, Dec 23, 2020.

  1. canis

    canis

    Joined:
    Oct 25, 2013
    Posts:
    79
    working on feature, to use specially jump animation to jump across obstacle.
    I manage to do that via Animator "MatchTarget" API.

    The goal was
    Jump via the specific obstacle we can apply different jump style,
    based on the { angle, distance, velocity }, in this case the white box on scene
    bonus : sometime the stylish jump will require the character interact with obstacle.

    here is current state



    code was functional, I calculate all those math stuff to define the start & end point, play animation correctly, MatchTarget functional..etc
    problem is the result was not good enough.
    here is the issue :
    • Matchtarget didn't care about physic collision, it looks like lerp between start to end point based on the information I provided.
    • some stylish jump require character interact with the obstacle,
      e.g. place hands on fence and jump across.
    • as video show, the character move across obstacle directly, sometime overlapped glitch happen.
    it generate several question for me, since I'm programmer, I'm not familiar the animation creation and tuning (I bought those on store).
    • Is this problem require Animator artist to solve above issue ?
      if so any advice or guideline can share with me?
      • e.g. how to achieve the "place hands on fence and jump across" jump with giving obstacle.
      • what if the obstacle height will change ?? on program side I can raycast and calculate the apex point of the obstacle, but how to implement it with Match target?
    • Is that possible to deal with instant acceleration during MatchTarget period.
      • I can only think of several amount of same jump animation with different distance.
        and I need to choose which one to play during that transition
    • I keep thinking I was using it wrong (MatchTarget), am I?? is there any other method can achieve the same thing ??
    • It looks like I better create the those path by myself really?! (e.g. bezier curve)
    If anyone deal with this issue before, please kindly give me the suggestion,
    any ideas are welcome.
     
  2. 00christian00

    00christian00

    Joined:
    Jul 22, 2012
    Posts:
    1,035
    You are going into pretty advanced topics, which even AAA games sometime screwup.
    I don't think you can fix it with match target.
    Some things you can do:
    1-Use IK for the arm, raycast from the body some rays to detect obstacles and make the arm land on a specific point on the box when the raycast detect an obstacle.
    You will blend between the original animation and the ik.
    2-Must deal with input buffering. Can't simply fire the animation whenever you want.
    If the target is near enough to a collider, schedule the animation for when he's actually at the right distance. Even with ik, if the target is too far the animation will look off.
    If the target is too distant, discard input.
    You must decide the tradeoff between look good and input lag/responsiveness.
    3-Yes, it's better if you make the path yourself. I am also using my own curves to drive rootmotion and you must also consider that with the jumps there is a certain momentum, first the legs muscles charge and then make the jump, cannot make the root move immediately or it will look off.
     
    canis likes this.
  3. canis

    canis

    Joined:
    Oct 25, 2013
    Posts:
    79
    at the end, I was using timeline to implement my jump feature.
    - pre-calculate the landing point
    - and allow small range correction, (major on rotation + Y-axis height)
    - use the timeline's path as data source,
    feeding delta position, rotation into my character controller.