Smooth raycast point with barycentric coordinates


I have a model that glides over the ground by raycasting downwards and adapting it's height depending on RaycastHit.point.

Now since the grounds mesh isn't in high resolution I get hard transitions between the vertices.

I already smooth the normals by using this nice little formula:

Now my question is, is it also possible to smooth the height of the vertices?

You could try Lerping it: Mathf.Lerp(start float, end float, interpolation 0-1). Something like:

transform.y = Mathf.Lerp(transform.y, desiredHeight, amount * Time.deltaTime);

"desiredHeight" - the height you want to be at, & "amount" - the sharpness of the follow. A figure of 0.05 is a fair starting point