rotate camera to face a specific object?

Hi,

I would like to move my camera at a specific moment, and make it look at a plane with an animated texture. So I would like to copy the rotation of the plane (that is outside of the landscape), and move the camera a little bit backwards so that it can look correctly at the plane.

But I can’t make it work: the first chunk of code does not rotate properly and the angle is not good, and the second chunk of code does not look at all at the plane … Would you know how to do this?

Here is the code :

void Update () {
		
		if (moveCamera){
			/*transform.position = toFollow.position;
			transform.eulerAngles = toFollow.eulerAngles;
			transform.position += Vector3.up * 8;
			transform.LookAt(toFollow.position);
			*/
			
			animation.Stop();
			Vector3 relativePos = toFollow.position - transform.position;
        	Quaternion rotation = Quaternion.LookRotation(relativePos);
        	transform.rotation = rotation;
        	transform.position = toFollow.up * 8;
		}
	}

EDIT :

Here is the image with :

transform.forward = -toFollow.up; (and the angle on the last image on the right) :

1259121-transform.png125

If I play with Quaternion, I only get a result with

transform.rotation *= Quaternion.FromToRotation(transform.up, -toFollow.forward); , but in this case it gives me exactly the same as the image above. ?

Thanks

Yeah planes are a pain because they kind face in the wrong direction!

This might well work for you:

transform.position = toFollow.position - toFollow.up * 8;
transform.forward = -toFollow.up;

or

 transform.rotation = Quaternion.LookRotation(-toFollow.up, Vector3.up); //Not sure what your up direction should be here