- Home /
Character Controller Side Collision
I have a player+character controller colliding with a platform. I apply gravity through script when the controller is grounded. Unfortunately, this method fails when the character is standing on the side of a platform:
As you can see, the character appears to fly over the platform. This occurs because the character controller believes it is grounded. Is there an elegant way of solving this problem (perhaps one of the controller's parameters)? If not, what could I do?
Thank you!
Answer by SirBoboHobo · Apr 08, 2015 at 02:00 PM
you could adjust the collider of the platform and make it smaller, that way it'll look like the character is standing on the platform, like cut a bit off the edges, or instead of using capsule collider maybe try something more accurate, polygon or even edge collider with a little bit of work to adjust it properly. EDIT: you could add an empty game object to the character that is in it's shape, and check whenever the that gameobject collides add gravity to the character, use GetComponent to get the character's gravity, or this.gameObject.parent
Thanks for your reply. I think that if I set the platform collider to be smaller, the character would be standing inside the platform at the edges (on the picture, you can see that the character is lower than the platform).
I think I could make it work by observing that OnControllerColliderHit has a collision point that is not underneath the character. In this case I would apply gravity. However, I would've thought that Unity had a built in way of fixing this problem... It seems pretty basic to me.
Your answer
Follow this Question
Related Questions
Player object: capsule with Character Controller goes through the floor randomly 0 Answers
Controller Collision Load Scene 2 Answers
3rd person controller camera passing through walls 0 Answers
Character controller fall through terrain 3 Answers
How can I have better physics interaction with a FPS Controller 1 Answer