So I’m attempting to make my character model as realistic as possible when it comes to how it interacts with the terrain. I’ve achieved making the model tilt in correspondence with the slope of the terrain using this bit of code…
RaycastHit hit;
Ray ray = new Ray(my_transform.position, Vector3.down);
if (terrain.Raycast(ray, out hit, 1000.0f))
{
my_transform.rotation = Quaternion.FromToRotation(my_transform.up, hit.normal) * my_transform.rotation;
}
However, this causes the model to slide backwards along the slope. I don’t want it to be Kinematic though, but I DO want it to be affected by Gravity. …but I don’t want the model to slide down the slope. Any thoughts?