Determining Rotation based on what's below vehicle

I’ve got a tank model that I’m currently planning out how it’ll calculate it’s rotation and height based on what’s below it. Every idea I’ve had to calculate it has flaws and I cant seem to come up with something consistent.

My attempts
First thought was to draw a raycast directly down from the center of the model, and just use the tangent line from the face it hit, however in that will lead to bad rotations in strange situations

Then I thought to draw raycasts directly down from the front and back of the tank to figure out where it will hit the terrain and then based on those calculate it’s updated rotation and Y value, but that has issues on hills positioning it slighly inside a hill.

I’m a little unsure about how to approach this if anyone has an idea I can test our let me know.

How about three raycast to get three points on a surface and use that to create a flat plane with a surface normal.

Similar to this resource:

1 Like

I think it’s exactly what I’m looking for. Thanks :+1: