Here’s the case:
In my game I have a 3D character controller that can walk, jump, interact etc. One of the core things to jumping mechanic - is checking whether the player is on ground on not. I’m doing that by Physics.CheckSphere method because it’s simple and effective:
But there comes a problem I recently discovered - if a character jumps and goes near a wall, script checks out that the character is on ground and he can jump. If he jumps, he doesnt go high because he’s bumping into a wall but he still can jump because he’s still near wall! That way if player mashes jump button, the jump force gets multiplied and this can be used to cheat. Here’s a video example of what I’m talking about:
Lowering groundDistance isn’t an option because level-design of my game consists of non-flat surfaces and the character is supposed to be able to stand on them.
Can yall help me with this?
Maybe I should use another method or maybe I should somehow check the object’s polygon rotation to figure if the surface is flat enough for it to count as ground?
SphereCast is good for detecting sloped ground and you won’t need to use a ground mask because it ignores anything that it overlaps at the start of the cast, like your player.