I’m in the midst of tinkering with an asset store pack to add ledge hanging functionality- I find myself diving into some mecanim applications for the first time and I could really use some pointers.
Below is a shot of the result of the mecanim matchtarget example. I’ve moved the target somewhat.
Had some progress, got the unity example working - (the issue there was simply that I had neglected to add a check for the statename of the animator state. Easy fix.) - but it seems my problem persists with the asset store controller system I’m trying to add to.
Above you see the weirdness. The large sphere collider is the target I’m trying to match to, the smaller target is generated by MatchTarget. As you can see, the character has been spun the wrong direction, and MatchTarget is not pushing the character to the correct height.
Code below:
void LedgeBottom() //Entering and exiting ledge from below.
{
animator.SetBool("EnterLedgeBottom", enterLedgeBottom);
animator.SetBool("ExitLedgeBottom", exitLedgeBottom);
// enter ladder from bottom
if (stateInfo.IsName("Ledge.EnterLedgeBottom"))
{
capsuleCollider.isTrigger = true;
_rigidbody.useGravity = false;
// we are using matchtarget to find the correct X & Z to start climb the ladder
// this information is provided by the cursorObject on the object, that use the script TriggerAction
// in this state we are sync the position based on the AvatarTarget.Root, but you can use leftHand, left Foot, etc.
if (!animator.IsInTransition(0))
{
MatchTarget(matchTarget.position, matchTarget.rotation,
AvatarTarget.RightHand,
new MatchTargetWeightMask(new Vector3(0, 1, 0), 0), animator.GetFloat("MatchStart"), animator.GetFloat("MatchEnd"));
}
if (stateInfo.normalizedTime >= 0.99f)
{
enterLedgeBottom = false;
}
}
Got it working! The issue before was in where the check for input was happening- the rotation was orienting the character according to the object itself rather than using the target transform, and match target wasn’t kicking in because the ground check didn’t have an exception for during ledge states.
Now I’m going to attempt to tackle ledge climbing on non-uniform ledges.