In the project, we often encounter that we want to move the camera to the front of a part for detailed close-up, and because the part selection is uncertain, we need to use code to set the position and orientation of the camera. code show as below:
public void StareModel() { targetVector3 = model.position + model.right * 5;//Set the camera's position 5 units away from the right side of the model Vector3 dir = model.position - targetVector3; //Get the orientation of the camera transform.DOMove(targetVector3,2f); Quaternion q = Quaternion.LookRotation(dir); //Convert orientation to quaternion targetEuler = q.eulerAngles; //Quaternions are converted to Euler angles transform.DORotate(targetEuler, 2,RotateMode.Fast) ; }