# How to be tangent with the ground without a character controller?

Hello. New to the Unity engine. Hope this is the right place to post.

I’m making a custom character controller for a game that has dynamic gravity. So I got a capsule mesh and a capsule collider. Good start.

Now the first step is to make the character fall when he’s not tangent to the ground, and not fall when he is standing on the ground. I can think of two potential ways to do this. 1) Apply constant downward force and trust Unity’s physics to prevent him from falling through the ground. 2) Use raycasting to determine when he comes in contact with the ground and then stop applying a downward movement, in order to keep him floating some minuscule distance above actually touching the ground.

What’s the more kosher way to do this? Which is more reliable?

Edit:

Okay. I think I was overthinking this. I didn’t realize how much Unity’s physics engine gave me.

So the current plan is to have a rotation-constrained rigid body collider for a player character. Gravity is applied (either through Unity’s gravity or my own scripted gravity). Then, on every frame, I shoot a real short ray out my feet to determine whether I’m currently grounded.

The physics engine makes me grounded; the ray tells me if I am grounded.

playing with forces can get quite messy fast. Id probably start looking at simple collision hulls and using OnColliderEnter() as that will give you control over hull penetration and triggering information.
The ground is just a collider after all, and the character is a capsule at this point, so as long as one of them has a rigid body, you’ll get collsion info.

Also, you can set up gravity to be any direction - just pass it a vector, so normal gravity is a vector 3 of 0,-9.81,0 and you can set change gravity whenever you like. Obviously, the more things using gravity the greater the potential for unexpected results…

The raycast, in a Coroutine to customize how often the raycast takes place