- Home /
Third person climbing?
None of the answers that I found on internet helped me. Please I hope that you can help. So basically I want to implement climbing on the object just like in GTA SA(for example I want to climb on custom box which is more or less my height or a bit less/or a table for instance). How do I make animation look natural? How do I naturally place the body,hands and feet depending on the height?
So I begun writing a function, but I realized that I can't answer those questions above.
ray = new Ray(transform.position,transform.forward);
if (Physics.Raycast(ray,out hit,rayCastDist,grabbableLayer))
{
CalculateTangent();
Debug.DrawRay(transform.position,ray.direction);
//get height and width
GameObject hitObject = hit.collider.gameObject;
if (hitObject.GetComponent<BoxCollider>())
{
BoxCollider box = hitObject.GetComponent<BoxCollider>();
//transform.eulerAngles = tangent;
float height = hit.transform.localScale.y * ((BoxCollider)hit.collider).size.y;
float width = hit.transform.localScale.z * ((BoxCollider)hit.collider).size.z;
if (heightOfJump > height && width>minWidth&&!isInGrabbingStage)
{
Debug.Log("Grab");
//ClimbOverFence();
}
}
Comment