I’m new to Unity and would like to know how I can make an object behind the camera move so that it looks like it’s being held in my hands. I know you can just throw an object into the camera, but that’s not what I need.I’ve already tried to write a script.
public class CameraScript : MonoBehaviour
{
public Transform ObjectPosition;
private Vector3 destination;
// Update is called once per frame
void Update()
{
destination = ObjectPosition.position + new Vector3(0, -0.2f, 0.5f);
transform.position = Vector3.Lerp(transform.position, destination, 0.1f);
transform.rotation = Quaternion.Lerp(transform.rotation, ObjectPosition.rotation, 0.1f);
}
Then you just need to update the above two points based on your GameObjects, no need to fiddle with rotations. As long as you move those positions smoothly, the camera will be nice and smooth as well, both positionally and rotationally.