We want to implement gravity which enables the player fall down to the ground. The player now has his position and motion as input. But the position only tells the location of x and z axis, not y axis. Hence, we want to make sure that the player is stick to the ground when walking. Otherwise, players will be floating above the ground or on the air if there is nothing behind the player.
We cannot directly add force to the player because the position and motion information are exact values of the transform. Now we try to use simple collision detection to achieve this goal. When the player does not collides with other object, he falls down. Otherwise he stops.However, when player moves between some objects, he will falls down a little because he exit the object.
Then we try to implement our own character controller. We find a useful post here: Custom SweepTest Collidion Detection hELP. However, the sweeptest function never works. We tested that the sweep direction was always (0, 1, 0) but it never detects the colliders right below it.
Can anyone give a suggestion how to realize the character controller like gravity on player?