i need to be able to change the x position of camera in the way i’m always looking at variable target, but just moving on right or left, so about a realtive x.axis , how can be done ? than u all for help.

I think if you hit up the transform.Translate method it will use the object’s relative axes. That is:daCam.transform.Translate(100, 0, 0); //translate 100 units along daCam's local coordinate system

This way i shoukd use progressive adjustments for x moving,meanwhile i have a value from -1 to 1 to use for camera moving, finally i need to move camera along an axis that is perpendicular to target object referred by lookAt

I explain what i’m looking for by sample Image, i have a camera looking at target, target can change , and i ned to move camera along an axis perpendicular to target, indipendently from rotation that is managed for lookAt, i saw some post, but got some difficult to start using vector, shoul di use a dot or cross product ?

transform.right (of the camera transform) should point in the correct direction after your quaternion stuff, so you can add or subtract that axis from your camera position to move along it.

Note however, that this will result in a circular motion, rather than a straight line.

The ‘right’ vector is always the same as the local x axis, regardless of orientation.

Are you perhaps trying to implement an orbital camera? That is, do you want the camera to rotate in a circle around the target, while always looking at the target?

The reason I ask is that if you actually move at a tangent (laterally), you’ll no longer be looking directly at the target. Since you’ve stated that you always want the camera to be looking at the target, and that you want the camera to be able to move laterally, it seems what you’re really looking for is an ‘orbital’ behavior.

It’s not quite clear to me then what sort of behavior you’re after exactly. If the camera is looking directly at the target and you translate along the local x axis, it will no longer be looking directly at the target. But, you said you always want the camera to be looking directly at the target (or at least that’s the way I understood it).

If you really just want to move back and forth along the local x axis, either of the previous suggestions (i.e. to use the transform ‘translate’ function or to translate along the ‘right’ vector) should work. Otherwise though, you might need to clarify what you’re trying to do exactly.

Maybe what you need to do is to have to objects, one being child of the other.

Then, use the translate on the parent (so everything moves) using the right axis, and LookAt on the child, in order to make the object point at wherever you need.

Ok. Well, if you just want to move back and forth along the specified line while always looking at the target, you’ll need to cache the translation vector, and then translate using that vector. For example (pseudocode):

// Global or member variable:
Vector3 right;
// At initialization:
camera.LookAt(target);
right = camera.transform.right;
// During update:
if (moveLeft) {
camera.transform.position -= right * speed * Time.deltaTime;
}
if (moveRight) {
camera.transform.position += right * speed * Time.deltaTime;
}
camera.LookAt(target);

nice, transfrom.right indeed made the difference, btw i need absolute values not relative, i mean i have to move camera step by step, if i have a movingfactor = .5 , camera has to be 0.5 shifted on the right along the right.axis, otherwise i’ll never be able to set camera in the starting centre using 0 value.

where right and forward are camera vector axis stored on start, so I’ll be able also to move on forward realtive axis keeping right lookAt rotation.
SelectedCamera is a nullpoint representing the startPosition of camera daCam