///////////////////////////////////////////////////////////////// // Checks obstacle dimensions and sets action bools ///////////////////////////////////////////////////////////////// private void ObstacleCheck(GameObject obj) { // Sets all actions to false playerObject.GetComponent <Player_Script>().ResetActions(); Vector3 obstacleBot = hitPoint; RaycastHit actionRay; float topHeight = obstacle.GetComponent <Collider>().bounds.size.y, botHeight, space, depth; // Get depth of mesh depth = GetDepth(); // Get height from ground obstacleBot += (transform.forward * depth / 2); mainRay = Physics.RaycastAll(obstacleBot, -Vector3.up, detectorLength); obstacleBot = GetFirstHit(mainRay).point; mainRay = Physics.RaycastAll(obstacleBot, Vector3.up, detectorLength); Debug.DrawLine(obstacleBot, GetFirstHit(mainRay).point, debugColour, 0.001f); obstacleBot = GetFirstHit(mainRay).point; botHeight = GetFirstHit(mainRay).distance; // Get height of top of obstacle from ground mainRay = Physics.RaycastAll(GetTopEdge(obstacle), -Vector3.up, obstacle.GetComponent <Collider>().bounds.size.y + detectorLength); topHeight = GetFirstHit(mainRay).distance; Debug.DrawRay(GetTopEdge(obstacle), -Vector3.up * topHeight, debugColour, 0.001f); // Get space above obstacle Physics.Raycast(GetTopEdge(obstacle) + (transform.forward * depth / 2), Vector3.up, out actionRay); if (actionRay.collider == null) { space = playerScript.GetJumpHeight(); } else { space = actionRay.distance; } Debug.DrawRay(GetTopEdge(obstacle) + (transform.forward * depth / 2), Vector3.up * space, debugColour, 0.001f); // Can slide if (obstacleBot.y <= playerObject.transform.position.y + playerScript.GetCrouchHeight() && obstacleBot.y >= playerObject.transform.position.y - playerScript.GetCrouchHeight()) { playerScript.SetCanSlide(botHeight > playerScript.GetCrouchHeight() && depth < playerScript.GetStandHeight()); } if (GetTopEdge(obstacle).y <= playerObject.transform.position.y + playerScript.GetCrouchHeight() && GetTopEdge(obstacle).y >= playerObject.transform.position.y - playerScript.GetCrouchHeight()) { // Can vault playerScript.SetCanVault(topHeight >= playerScript.GetCrouchHeight() && topHeight <= playerScript.GetStandHeight() && space >= playerScript.GetCrouchHeight() && depth < playerScript.GetWidth()); // Can mantle playerScript.SetCanMantle(topHeight >= playerScript.GetCrouchHeight() && topHeight <= playerScript.GetJumpHeight() && space > playerScript.GetCrouchHeight() && depth >= playerScript.GetWidth()); } // Can climb else { playerScript.SetCanClimb(topHeight > playerScript.GetJumpHeight() && botHeight < playerScript.GetStandHeight() && (hitPoint - playerObject.transform.position).magnitude <= reach); } }