I’m working on my player controller and have everything really smooth and robust except the jumping feature. In an effort to reflect real world physics as much as possible, I’m trying to make sure the player model is able to “jump” in a direction normal to whatever surface they are colliding with. I’m thinking similar to the way Titanfall allows the player to wall-run and jump. However, this poses a couple of problems.
There doesn’t seem to be a way to determine if a collider is colliding with anything on demand. This would be useful because all that would be required to implement a jump feature would be to grab the player collider, run a test to see if it has any points of contact and if so, where on the player collider those points of contact are. Once those points of contact are determined, use the vectors to those points from the center of the collider and create a vector that is the sum of those vectors. This vector would dictate the direction that is normal to all points of collision. Then jump in that direction.
I’ve tried looking up CapsuleCollider methods, raycast methods, OnCollision methods, but I feel like I’m missing how to utilize these to get the functionality I’m desiring. I’m sure using OnCollisionStay would work but that sounds like computational overkill as I’m really only interested in changes in collision state, i.e. when a player stops contacting a collider, check to see if the player has any points of collision; if no, then the player is airborne and can’t jump.
My question then is: is there a good way to perform on-demand collision point checking in all directions of a collider?