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) :
125
125
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