Offset Player Position

Hello,

I currently have a player object which is controlled using a rigid body relative force in the forward direction the cube is rotated.

I am trying to get the other cube (which is not a rigidbody) to copy the rotations, positions of the player but with an offset of its original position and rotation.

I offset the position and rotation using:

transform.rotation = PlayerHead.transform.rotation * originalRotation;
transform.localPosition = PlayerHead.transform.position + originalPosition;

But I’m not sure how to apply the players movements relative to the other cubes rotation.

The second cube currently moves in the same direction as the player cube no matter which way it is facing, Does anyone know how I should apply the movement of the second cube so that it is applied in the direction it is facing.

Any info would be appreciated, thanks.

It shoud work:

public Vector3 offset = new Vector3(-1, 0, 1);

void Update() {
   transform.position = PlayerHead.transform.position;
   transform.rotation = PlayeHead.transform.rotation;
   transform.position += transform.TransformDirection(offset);
}