Search Unity

Best way to handle climbing ON an animated skinned mesh?

Discussion in 'Scripting' started by PrimeDerektive, May 8, 2013.

  1. PrimeDerektive

    PrimeDerektive

    Joined:
    Dec 13, 2009
    Posts:
    3,090
    I'd like to accomplish something like Shadow of the Colossus style climbing an animated giant.

    Due to the size of the creatures, simply parenting primitive colliders to the creature's bones will not suffice. The climbable surface needs to be pretty much 1:1 with the skin.

    Its pretty easy to forcibly recalculate the collision mesh to match the animated SMR (as seen here), and given that there will never be more than one creature on screen, it doesn't perform too terribly, but I'm open to suggestions.

    But as for the actual climbing, the character will need to not just get the point on the animated mesh, but also move with the animation, while climbing. I'm pretty stumped on how to figure that one out.

    I thought about maybe just figuring out the initial "climb" raycast hit position relative to the position of the nearest bone of the animated mesh, and keeping the character positioned with that, but it would get slippery in-between bones I think.

    I also thought about figuring out the triangle from the hit triangle index, then calculating the position within the triangle, and keeping the character in-line with that, but I'm not sure how to go about it and I think it might be terribly CPU intensive.

    Any thoughts?

    cross-post
     
    DizzyTornado likes this.
  2. PrimeDerektive

    PrimeDerektive

    Joined:
    Dec 13, 2009
    Posts:
    3,090
  3. OhNoDinos

    OhNoDinos

    Joined:
    Feb 16, 2014
    Posts:
    6
    Trying to do the same thing basic, and I saw this post a while ago. But since I imagine others will stumble across this at some point, I have some ideas on the subject.

    You'll basically need to have the climbing character be effected by the bones of the larger model in the same way its own vertices are. To do this, you'll need to use Mesh.BoneWeights to find how the nearest vertex is being affected, and then calculate your target position based on this data.

    Better than a single vertex, you can get the triangle that you're attached to (first by looping through all vertices to find the closest to your character, then using that location to simplify the search as you move across the surface) to calculate both position and rotation change relative to the bone influences of the triangle corners.

    You would want to be parented to the larger creatures transform so that the overall movement would affect you, and then modify your localPosition based on these calculations.

    I haven't tested any of this, and I'm not sure what the specific calculations would look like, but it's a jumping off point. I'll be trying to develop a system for this in the near future, and I'll be sure to post if it's successful.
     
    DizzyTornado likes this.
  4. DizzyTornado

    DizzyTornado

    Joined:
    Nov 17, 2013
    Posts:
    134
    Interesting.