How to make a part rotate towards the ground?

I’m making a wild west themed game and I currently making a horse for the player to ride. I want it so that the horse always orientations towards the ground. If the horse is on a slope, they face the slope realistically. How would you go about this??

Mathwise, you can do 3 downward raycasts around the horse near the floor to form a triangle, then either average their normal vectors or compute the cross product of the 3 points (via (B - A):Cross(C - A).Unit). Just make sure the dot product of the vector against Vector3.yAxis is > 0, otherwise the vector somehow turned upside down.

I’ve never been much of a mathematician, especially in code (I’m a beginner atp). Do you know how I can make a raycast triangle??

Does your horse move using physics, or are you handling everything programmatically?


Raycast down from 3 points of the horse, but you may also be able to get away with using just one from the center of the horse if you’re using physical constraints.

RaycastResults have a Normal vector that you can use to determine the slope.

(math isn’t really my thing either, but this should be correct)

Not sure yet, probably will do a physics approach?