#Issues with Ground Check for the Character Controller

1 messages · Page 1 of 1 (latest)

edgy kernel
#

Hey there!

I am trying to make a better ground check for my character controller, but I constantly having issues, where the fix for one issue brings another one like in a loop.

I use a spherical cast that occurs at the player's feet to detect whether they collided with the ground or not. When they do - the gravity gets reset to -2f once, since i saw that happen in the tutorial. But because the detection is spherical, there is an unwanted interaction where the player would snap to the ground whenever the sphere touches a ledge, essentially making jumping over an obstacle snap the character to the top of it.

And here are the fixes I tried: decreasing the size of the sphere or changing to a raycast DOES fix the issue, but a new problem arrives where the player can stay very close to the edge of the object and constantly accumulate gravity. Their collider is still on the object, so they dont fall, but because the raycast/spherecast projects downwards and doesn't hit any ground - it puts the player into an airborn state.

How can i prevent both issues from happening?

#

I was thinking about switching from the bean collider over to the box collider and check whether the bottom face of the box is on the ground. It would certainly help with ground detection, since sides would prevent ledge cases(hehe) like that from happening.

#

But I'd like to see, maybe there are better solutions to this problem. I also don't know how to exactly switch to box collider and how to only check for the face collission but thats solvable

#

the bean is still technically on the ground, but the ground check fails in this situation

#

And here's the example of the behavior where the character snaps over the ledge

edgy kernel
#

So far I reduced the issue with ledge snap by fiddling with the height, skin width and ground check position to be as close to the ground while also being away from the edges of the bean as possible

#

The ledge snap still persists but its not as severe anymore

keen oracle
#

I use a spherical cast that occurs at the player's feet to detect whether they collided with the ground or not. When they do - the gravity gets reset to -2f once, since i saw that happen in the tutorial.
What do you mean by "the gravity gets reset to -2 once"? I think you mean the vertical velocity?

#

constantly accumulate gravity
Yeah you're definitely confusing gravity and velocity here

#

But because the detection is spherical, there is an unwanted interaction where the player would snap to the ground whenever the sphere touches a ledge, essentially making jumping over an obstacle snap the character to the top of it.
I feel like this would be fixed very simply by reducing the range of the spherecast. Make it extend only like 0.05 meters past the character's feet, or less.