- Home /
Flipping object with Box Collider while on an angled collider
I'm using a premade character controller (made by Sebastian Lague during his video tutorials) which is based on raycast collisions. It works perfectly, but doesn't account for flipping the player object to face the opposite direction, which breaks on slopes due to the flip causing the attached BoxCollider to intersect with the angled slope collider (either Edge or Box).
Here's a visual of it:
For the flip, I'm just doing a simple transform.localScale
change when velocity is positive or negative. I could just change the sprite flip, but the collider wouldn't match it, so I opted to flip the entire thing.
I tested rotating the player object to match the angle of the slope and as expected, no clipping of colliders. So I tried using a front and back raycast to deal with rotating based on hit.point
normals, but since the controller doesn't actually have variables for each raycast (it uses a loop and iterates through the amount of rays).
Is there any way to efficiently handle the colliders clipping into other colliders when it's flipped in close proximity?