Hello, everyone.
I’ve been trying to find a suitable algorithm for checking the ground under the player’s feet for two weeks now, and I haven’t come up with anything.
Let me explain: to adjust the player’s direction of movement, I need to get the surface normal (as in all tutorials), but SphereCast/CapsuleCast at the edges give the normal in the direction of the point of contact, not the real one. Because of this, the player “slides down.” The effect is shown in the image below.
This isn’t the first time I’ve seen this in various controllers, but I don’t like this effect. I’m guided by games such as Quake, Half-Life 2, and Portal 2, where this doesn’t happen.
When studying the above games using the console, I discovered that they used BoxCollider instead of CapsuleCollider. However, I am told that no one does this now, although I do not understand why.
In general, please point me in the right direction. I cannot yet figure out the best course of action on my own, as I have little experience in game development.
Thanks in advance!
#Ground checking problem
1 messages · Page 1 of 1 (latest)
You can certainly use a box collider if you want, it has its own drawbacks.
But I'm not sure I understand the relationship between the shape of your collider, the shape of your cast, and the normal you're getting/using here, not what you're doing with the normal exactly
I have a player context script where I record the surface normal obtained from the ground check script. In the ground check script, I do a SphereCast down relative to the player's position and take the normal from the hit. And then in the movement script, I project the movement vector onto the normal plane (like this: Vector3.ProjectOnPlane(desiredDir, groundNormal).normalized).
I apologize if I misunderstood you; English is not my native language.