I have some code where my character can "climb up" onto an object in front of them. Right now, I'm using a RaycastHit to determine if a climbable object exists in front of them and that part works great. Now I want to be able to detect the height of the collider plane in front of the player. I'm attempting this with the "mpCenter" vector and using a Bounds.Contains with marginal success.
What I'd really like is to know exactly what the world coordinate is of the tallest point of the colliders surface for my initial RaycastHit. That way, if it is a box collider for a wall for example, then i want the height of the plane (normal?) in front of the player - which will allow me to adjust my animation accordingly (i.e. if its about eye level then just play the climb up on ledge animation, if its a few feet above them, then play a jump animation first to get the player to the right height, then play climb up on ledge).
RaycastHit hit; if( Physics.Raycast( transform.position, transform.forward, out hit, 0.35f ) ) { // check if this is a climbable object or we are free to jump if( hit.transform.gameObject.tag == "Climbable" ) { Vector3 mpCenter = new Vector3( hit.point.x, rigidbody.position.y + jumpHeight, hit.point.z ); if( !hit.collider.bounds.Contains( mpCenter ) ) { animation.CrossFade( "ClimbUpOnLedge" ); } } }