Rigidbody Lerp to Mouse position from Raycast

Basically I wanted to have a script that was only attached to the main camera (in this case the one attached to a custom FPS Character) and when a Raycast would hit a Rigidbody, it would disable its gravity and Lerp it to where the Player would look. So basically when the Player clicks on the rigidbody, at no matter what distance from the Rigidbody, he can manipulate it’s position (and later on it’s rotation) just by looking around, similar to how the Physgun works in Garry’s Mod.

First use Physics.RayCastHit to get the gameobject you are looking/hitting . Then disable its physics using rigidBody.isKinematic = true . Then use Physics.RayCastHit with ground layer to find the position your looking and then use transform.position = Vector3.Lerp(yourObjectPsotion,lookingPosition,Time.deltaTime * lerpingSpeed) to manipulate the object your are looking or hitting.