- Home /
3rd person character controller walking down hill
Ive followed a tutorial on 3dbuzz link on a 3rd person character system. The system uses character controller component and not rigidbody. The problem im facing is walking down hills in my terrain, when i walk down a hill the character walks out into nothing horizontally then falls back to the ground. Ive tried using a raycast to detect when im not grounded and forcing character to the ground, but it gave a lot of stutters and when i walk upwards the hill the character sometimes fell through the terrain.
RaycastHit hit;
if (Physics.Raycast(transform.position, Vector3.down, out hit)) {
transform.position = hit.point;
}
Thank you good sir, i have seen this answer multiple times but havent figured it out, it just hit me when i read ur comment. So i added if (tpController.CharacterController.isGrounded) { $$anonymous$$oveVector = new Vector3($$anonymous$$oveVector.x, VerticalVelocity + -1, $$anonymous$$oveVector.z);
} If u want to convert your comment to an answer i will accept and upvote :)
Answer by hexagonius · Feb 23, 2015 at 05:53 PM
The character controller needs a constant push downwards. If you're using move to move it just increase the negative y on it while grounded. If you're using simplemove increase the global gravity in the settings.
If both is not ok, raycast the ground where the controller would be with its next move command and recalculate the move vector so it is parallel to the ground
Your answer
Follow this Question
Related Questions
Distribute terrain in zones 3 Answers
Multiple Cars not working 1 Answer
UnitySteer and physics collision 1 Answer
Motion over sloped terrain 0 Answers