# Best way to align ridgidbody skateboard with floor?

I want the board to align to the floor (ramps/uneven surface) without the whole thing falling over. I dont want the standard raycast down from the middle > get floor angle> set whole thing to floor angle, because that doesn’t look right in certain situations and doesn’t give the phyical feel.

Limiting how much the ridged body can rotate somehow
Setting a toque to the upright position
Human always faces up and pushes down on the board

I don’t have any experience with at, so slap me and call my Valentine, but… couldn’t you just use WheelColliders for the wheels and an other collider for the board and let the physic engine handle everything else? With a handy script you can also control the wanted alignment of the rigidbody for the whole construct. As the player has weight/mass he will also push down the board on his own.

“couldn’t you just use WheelColliders for the wheels and an other collider for the board and let the physic engine handle everything else?”
Basically what I’m doing now

“control the wanted alignment of the rigidbody”
Yeah that’s my first idea but I’m not really sure how to go about doing it. I could do something like ‘if x angle > 45, x angle = 45’. But that would probably be quite jankey with a ridgedbody

You could use a Lerp or Slerp to smooth the raycast hit normal giving it a more natural feel.

``````float rotSmooth = 5.0f;
RaycastHit hit;
if (Physics.Raycast(transform.position, -transform.up, out hit))
{
transform.rotation = Quaternion.Lerp(transform.rotation, Quaternion.LookRotation(Vector3.Cross(transform.right, hit.normal), hit.normal), Time.deltaTime * rotSmooth);
}
``````

Increase rotSmooth for a quicker transition, decrease it for a slower transition.

Even better would be to raycast from each wheel and average the normal hits to smooth transitions between surfaces even further.

I’ll try that last idea
Since the wheels are raycasting a already is there anyway to get the normal from their hit?

That would still make it float in the air if the back wheel where on a surface higher than the front wheels

There are several ways to do this… I suppose you could create a public array of Vector3 for the normals and use OnCollision in a script on each wheel to set them sending a message from the wheel script to the script that does the rotation smoothing.