I have a function that lerps an object in front of the camera to "pickup/hold" said object. However, while holding the object, if I hit it against another object a certain way, the held object will rotate in an unexpected way. I am not changing the rotation of the object anywhere in my script. What is going on and how could I fix this so that it rotates properly? This is what it looks like
void Grab()
{
if (musketState == MusketState.Grab)
{
objectToGrab = hit.transform.gameObject;
Rigidbody objectRigidbody = objectToGrab.GetComponent<Rigidbody> ();
Vector3 desiredPosition = mainCamera.transform.position + mainCamera.transform.forward * grabDistance;
Vector3 smoothedPosition = Vector3.Lerp (objectToGrab.transform.position, desiredPosition, smoothSpeed * Time.deltaTime);
isGrabbingObject = true;
objectRigidbody.useGravity = false;
objectRigidbody.transform.position = smoothedPosition;
}
}