Getting the SurfaceNormal for a horse

So, I have been messing around trying to get the SurfaceNormal of a ray being casted down from a seat. Im attempting to get a horse to stand oriented with the ground.

This is my code…


local function UpdateSurfaceNormal(seat, gyro)
	local ray = Ray.new(seat.Position, Vector3.new(0, -20, 0))
	local target, position, surfaceNormal = workspace:FindPartOnRayWithWhitelist(ray, {workspace.Terrain})
	local slopeAngle = math.atan2(surfaceNormal.Z, surfaceNormal.Y)
	gyro.CFrame = seat.CFrame:ToObjectSpace(CFrame.Angles(slopeAngle, 0, 0))
end

This is my result…
ZyYBtjY
Any suggestions or advice on how I can get this to be more accurate? To clarify, I’m casting a ray from the center of the seat (middle of the horse), down to the ground. Im also using a BodyVelocity to move the horse forward/backward.

2 Likes

Did you find any solutions? Im having the same problem

Perhaps ray trace down from the horses hooves.

Use the built-in property Normal. RaycastResult.Normal

1 Like

Did you find any solution for this, I am currently making a horse and having the same problem.