Position on a Vector3 at specific distance

I have a grid in which individual cells are focused on to and the camera pans so that it’s on a vector drawn from the grid’s center and through the cell. I am trying to set the camera at a certain distance from the cell on the vector, but can’t get the math right. Simply factoring the vector obviously gives varying distance, although it is on the vector. Adding to it gives errors or I’m not doing that right.

``````Vector3 diff = target.position - container.transform.position;
``````

That’d be the vector between container and the currently focused grid cell. What do I have to do to diff to find the position on the vector on the other side of the cell at a distance, say, 4?

EDIT: (can’t seem to remove the question on my own)

Five minutes after posting this I arrive to the conclusion, I think, on my own:

Vector3 camPos = cell.position + diff.normalized * 4;

Here’s the solution in C# (also edited in the first post):

``````Vector3 camPos = cell.position + diff.normalized * 4;
``````

Or in JS:

``````var camPos:Vector3 = cell.position + diff.normalized * 4;
``````