I'm making a camera that can currently rotate freely from the back to the front of a target object by giving it an angle and a distance.
I do the above with the following code
directionVector = new Vector3(0, Mathf.Sin (angle*Mathf.Deg2Rad), Mathf.Cos(Mathf.Deg2Rad * angle)); normalizedDirectionVector = (directionVector).normalized; transform.position = (normalizedDirectionVector*cameraDistance) + target.transform.position;
In the above I take the direction from the angle, normalize it and then add it to the target position. And the camera sets nicely to the wanted angle. But how can I add the sideways movement(x-component) so that I could move the camera freely around the target?