- Home /
How to avoid 3rd person character run on wall?
Question: If my 3rd person character jumps against a cliff wall which is not absolutely perpendicularly, then he is able to run on that wall.
Any idea how to avoid it? I still have a ridgidbody on the character. I also tried to add a physics material with 0 friction to the cliff, but it doesn't help. For the movement I use a character controller.
What I want, is that he slides down the wall.
thanks in advance Frank
First of all: Don't mix CharacterControllers and RigidBodies. They are incompatible. The CharacterController has a max slope value.
I have seen the max slope value, but I has no effect to the character when jumping against a slope. If I try to run against it, the max slope value seems to work, but if I jump the character stays at the slope and is able to run upward.
Answer by Ill-Fish · Aug 24, 2015 at 04:06 PM
Ok I found a solution:
void OnControllerColliderHit(ControllerColliderHit hit)
{
// Sloping
myAng = Vector3.Angle(Vector3.up, hit.normal);
slopeDownTargetPosition = hit.normal;
slopeDownTargetPosition.y = hit.normal.y *-1;
Debug.DrawRay(hit.point, slopeDownTargetPosition, Color.white);
if (cc.isGrounded && myAng > cc.slopeLimit)
{
isSloping = true;
cc.Move(slopeDownTargetPosition * Time.deltaTime);
} else {
isSloping = false;
}
// Pushing
CollisonBody = hit.collider.attachedRigidbody;
if (CollisonBody != null && !CollisonBody.isKinematic)
CollisonBody.velocity += cc.velocity;
}
cc is my Charater Controller.
Your answer
![](https://koobas.hobune.stream/wayback/20220612001109im_/https://answers.unity.com/themes/thub/images/avi.jpg)