Hi,
I’m making a 3D game since a while and i always noticed that my player when it comes to high slopes, can’t just stay blocked in front of it but tries to climb and fall through the collider. I don’t know what to do at this point, i think everything is configured correctly.
My player stays on the ground with two legs that have a capsule collider each.
The player doesn’t go that fast.
My colliders are not triggers
The terrain has a mesh collider
I tried putting one single big capsule collider and the same issue occurs.
My rigidbodies are both (player and terrain) continuous dynamic
Making it interpolate doesn’t do anything
My physics update time is 0.2
Most likely the cause has to do with the way you are moving the player’s rigidbody. Operations like modifying Transform.position, Rigidbody.position or calling Rigidbody.MovePosition bypass the physics calculations, and frequently this is the cause of rigidbodies passing through colliders. The correct way for moving rigidbodies so collisions and frictions are simulated properly is calling Rigidbody.AddForce from FixedUpdate. See:
Apart from that, the terrain doesn’t need a Rigidbody. If you read the console, you’re already receiving errors because rigidbodies can use convex colliders only, and you’re trying to assign a non-convex collider to a Rigidbody. You can just remove the Rigidbody component from the terrain collider, it’s doing nothing.
You may also want to look into Kinematic Character Controller since that handles pretty much all of the hard edge cases that the default CharacterController component doesn’t.
That seems to work well concerning the shifting, but when i fall, the player has a non-realistic fall with constant velocity, how can i handle that ? Is it mandatory to check if the player is on the ground ?
On another part, this method makes my jump look weirdly fast on the rise, it is made by a rb.AddForce in force mode. ( i think i can fix it by detecting the jump input and making it a condition to skip the velocity movement command )