I have a rigid body which moves in different angles through a floor. (0,90,270)
While moving, camera should move according to the rigid body.
How to change direction of main camera?
Try parenting…just drag and drop the camera upon the object and it will work…for changing the direction of camera you can try rotating tool in unity 3d shortcut for it is to select the object and press e and rotate threw the circles or rotate it from inspector…
Try this code(put this script on element which is moving):
Vector3 relativePos = transform.position - Camera.main.position;
Quaternion rotation = Quaternion.LookRotation(relativePos);
Camera.main.rotation = rotation;