I am building a free climbing system for a 3d Game like in Genshin Impact but I can't get my player to climb up the edge,
I used double raycast to detect if it's an edge or not, if there is an edge, the animation is triggered and I used matchTarget as shown here
private bool edgeDetect()
{
RaycastHit firstHit;
Vector3 position = transform.position + detectionOffcet;
if (Physics.Raycast(position, transform.forward, out firstHit, 2f))
{
if (Physics.Raycast(firstHit.point + (transform.forward * playerRadius) + (Vector3.up * 0.6f * playerHeight), Vector3.down, out var secondHit, playerHeight))
{
Targetposition = secondHit.point+edgeOffcet;
m_Animator.SetTrigger("edge");
Vector3 climbEnd = secondHit.point;
m_Animator.MatchTarget(climbEnd, Quaternion.LookRotation(-firstHit.normal), AvatarTarget.Body, new MatchTargetWeightMask(Vector3.one, 0), 0, 0.09f);
return true;
}
}
return false;
}
but this is not working properly, the player always falls and does not reach the edge, he gets stuck , Also if the wall is diagonal the detection system will be wrong, how how can I fix this