Make an object snap to other object smoothly and not instantly?

I am creating an IK foot system, but I need the foot to snap to the ground, like smoothly snap to the ground, like a cube or terrain, or whatever.

Could you post an example of a code, where some object snaps to another slowly, like not instantly appearing from one place to another, that would be very useful.


You should use Vector3.Lerp. Don’t know your variables but

private float startSnap;
private float howFar;

// startPoint is the transform you're starting from
// endPoint is the transform you're moving to
startSnap = Time.time;
howFar = Vector3.Distance(startPoint.position, endPoint.position);

// then each frame call the following

float distCovered = (Time.time - startSnap) * 3;
float fracOfJourney = distCovered / howFar;
transform.position = Vector3.Lerp (startPoint.position, endPoint.position, fracOfJourney);

You can get the same info from the ScriptReference Here

Hope that helps