- Home /
Step Offset for Rigidbody Character
I'm working on a Rigidbody Character Controller, and I've got most of it done. The thing that's really puzzling me is in trying to make a Step Offset for it, like the basic Character Controller has.
Might someone have a suggestion?
This is very old, but I just ran into the same issue, did you ever solve it? Or does anyone else know?
I did not think this through but it might work with two short raycasts. One points forward from the lowest point of the caracter the second one points in the same direction but is Step Offset higher. If the first raycast detects a wall but the second does not then move the caracter upwards.
Answer by Dorscherl · Jul 22, 2019 at 07:37 AM
This is something I've had difficulty with as it's hard to produce smooth results. I shot a raycast to the ground originating from transform.position + (transform.up stepHeight + offset) + (moveDirection.normalized (capsuleRadius + capsuleRadiusOffset)) to put the origin slightly above the max step and in front of the capsule in the desired move direction. Then you shoot the raycast the stepHeight. If you hit something you can either lerp the transform position to the hit point with a stepSmooth variable or subtract the hitPoint from the transform position and add that offset to your movement vector. (this is off the top of my head)