Offsetting local positions

I have been trying to figure out how to use a vector3 as a offset for local transforms in scripting.

Ex: An orbit camera looking at a the player. I want to use a vector3 to position the lookat point slightly to the right of character. Also, when I rotate the camera, the offset should rotate with the camera so the offset stays on the right. Instead of that happening, the offset moves the lookat point on the world x-axis instead of the local axis.

How do I get it to offset on the local axis?

So you want the position to be on the right of the player relative to the camera?

You are close, you just have to move it with the cameras axis instead of world as you said.

It can be done like this:

Vector3 playerPosition;
float xOffset;
Camera camera;

Vector3 lookAtPoint = playerPosition + (camera.transform.right * xOffset);

Why not use a empty gameobject ?

You create a gameobject “target” set the character as parent of this target (on the editor), your camera look at this target, so when you move / rotate your character, the target follow the movement and your camera still look at the right point.

(And maybe set the camera the children of this target).