tank movement on uneven terrain

I have one tank AI need move along with terrain and I try to use raycast to determine the Y position of the tank when it is moving. this settle a little part of the problem.
what is question is that if terrain height is heigher than tank’s current height, how can I reset tank Y position to fit the height of terrain,let it looks like tank move on terrain surface instead of going throught terrain.

you can ad a character controller to the tank and use its functions like “move” to move the tank. it will respect colliders and terrain. check the reference docs for “Character Controller”

Tray This Unity Easy Tank Arcade Game Part 2 - YouTube