Need to keep an object in front of the player facing toward the camera during movement

I’m trying to place a 3d object in front of the player (this is in a first person camera mode) and have that object remain facing the player when they move around. Ultimately the goal is for them to be able to write on the object in realtime when moving around but that’s for later. Currently I’m trying to get the rotation to work properly but it’s not quite right.

To get the object in front of the player initially, I am using a Coroutine:

IEnumerator BringPaperInFrontOfPlayer()
{
    if (Camera.main == null)
    {
        Debug.LogError("No main camera selected for player!");
        yield return null;
    }

    var modelTransform = currentDrawingModel.transform;
    var targetPos = playerController.DrawingStopPoint.position;
   

    while (modelTransform.position != targetPos)
    {
        targetPos = playerController.DrawingStopPoint.position;
       
        modelTransform.position = Vector3.MoveTowards(modelTransform.position, targetPos, Time.deltaTime * 2f);
       
        yield return null;
    }

    modelTransform.rotation = Quaternion.LookRotation(Camera.main.transform.forward, currentDrawingModel.transform.up);

   

    paperInFrontOfPlayer = true;
}

This brings the object in front of the player, although the rotation doesn’t seem to be correct. I did check the clipboard model that I’m using to make sure the axes are correct and they seem to be (i.e. moving the object forward and backward from input moves it correctly along the blue forward axis). I thought that using the LookRotation with the camera forward and the model up would align them.

Secondly I need to keep the object facing the player when they look around. In the LateUpdate function I’m also using LookRotation:

currentDrawingModel.transform.rotation = Quaternion.LookRotation(Camera.main.transform.forward, currentDrawingModel.transform.up);

I have a zipped video that I uploaded showing what is happening. It’s definitely rotating with the player, but not correctly and I think the position needs to change to maintain the proper distance as the player looks around.

I thought about Slerping (it looks like Slerping would match the desired rotation and position change?) but my understanding is that it’s meant to be used when there is a need for change over time instead of immediately? Any help is appreciated, even if it’s just resources that might be valuable.

9745786–1394593–2024-04-02 13-20-22.zip (4.71 MB)

Try setting the rotation with this:

modelTransform.rotation = Quaternion.LookRotation(Camera.main.transform.forward, Camera.main.transform.up);

That didn’t work. I feel like it’s so close though. I tried using RotateTowards and I think mechanically it’s working, but the rotation of the object seems to have the .forward of the vector pointing toward the camera, and attempts to force the .up Vector point at the camera haven’t worked so far.

As a quick around just add a rotation on top of that to make it face the way you want… hey as long as it works!

Ok, I did get it working! I had to change the axes of the original object by making an empty object, setting it into the center of the object, then setting the new empty object as the parent of the old. I guess that means it WAS my axes in the first place? I have much to learn. Thanks folks.