- Home /
Using a perspective camera can an object act as if viewed by orthographic camera?
Is it possible to maintain the visual appearance of an object when moving or dragging in a scene with a perspective camera?
The the object is on the extreme left size of the cameras view we can see the right side of the object and the left is hidden similarly on the extreme right side of the camera the left side of the object is visible.
My issue is similar to this question but I need a unity solution.
I'm thinking a script with some combination of LookAt and LookRotation in relation to the camera but I can't seem to figure it out.
Answer by rendered_monkey · Mar 06, 2017 at 10:31 PM
I figured this out. Ended up creating a simple script that orients the object towards the camera. There is still warping at the edges due to the fisheye effect but otherwise the objects remain as intended.
public class KeepPerspective : MonoBehaviour {
private Vector3 original;
void Start () {
original = transform.eulerAngles;
}
void Update () {
GameObject target = Camera.main.gameObject;
Vector3 position = target.transform.position - transform.position;
transform.rotation = Quaternion.LookRotation(position);
transform.rotation = Quaternion.LookRotation(position) * Quaternion.Euler(
original.x, original.y, original.z);
}
}