private void FrontCollisionTest() { if (isWallrun_Right || isWallrun_Left) { return; } RaycastHit hit; if (Physics.Raycast(transform.position, transform.forward, out hit, 1 + controller.skinWidth)) { var maxBounds = GetBounds.GetMaxBounds(hit.transform.gameObject); //Debug.Log(maxBounds.max.y - transform.position.y); if (maxBounds.max.y - transform.position.y > 1) { if (Vector3.Dot(hit.normal, Vector3.up) == 0) { isClimbing = true; WallClimb(); // Debug.DrawRay(hit.point, Vector3.up, Color.blue, 10f); } else { isClimbing = false; } } else { isClimbing = false; } } }
private void WallClimb(RaycastHit hit) { if (isClimbing) { var maxBounds = GetBounds.GetMaxBounds(hit.transform.gameObject); Debug.Log(maxBounds.max.y - transform.position.y); if (maxBounds.max.y - transform.position.y > 0.1f) { isClimbing = true; vel = Vector3.up * 5; Debug.DrawRay(hit.point, Vector3.up, Color.blue, 10f); controller.Move((vel) * Time.deltaTime); } else { transform.position = new Vector3(transform.position.x, maxBounds.max.y + 0.1f, transform.position.z) + transform.forward; lastClimbedWall = hit.transform; if (tmpVel.y != jumpVel) { tmpVel.y = jumpVel; } controller.Move((tmpVel) * Time.deltaTime); isClimbing = false; } } animationController.SetBool(anim, AnimationManager.AnimationStates.climbing.ToString(), isClimbing); // controller.Move((vel) * Time.deltaTime); }